MythTV  master
dvbchannel.cpp
Go to the documentation of this file.
1 /*
2  * Class DVBChannel
3  *
4  * Copyright (C) Kenneth Aafloy 2003
5  *
6  * Description:
7  * Has the responsibility of opening the Frontend device and
8  * setting the options to tune a channel. It also keeps other
9  * channel options used by the dvb hierarcy.
10  *
11  * Author(s):
12  * Taylor Jacob (rtjacob at earthlink.net)
13  * - Changed tuning and DB structure
14  * Kenneth Aafloy (ke-aa at frisurf.no)
15  * - Rewritten for faster tuning.
16  * Ben Bucksch
17  * - Wrote the original implementation
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 2 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32  */
33 
34 // POSIX headers
35 #include <fcntl.h>
36 #include <unistd.h>
37 #include <utility>
38 #include <sys/poll.h>
39 #include <sys/select.h>
40 #include <sys/time.h>
41 #include <sys/types.h>
42 
43 // MythTV headers
44 #include "mythconfig.h"
45 #include "mythdb.h"
46 #include "cardutil.h"
47 #include "channelutil.h"
48 #include "dvbtypes.h"
49 #include "dvbchannel.h"
50 #include "dvbcam.h"
51 #include "tv_rec.h"
52 
53 // Returned by drivers on unsupported DVBv3 ioctl calls
54 #ifndef ENOTSUPP
55 #define ENOTSUPP 524
56 #endif
57 
58 // Local functions
59 static void drain_dvb_events(int fd);
60 static bool wait_for_backend(int fd, int timeout_ms);
61 static struct dvb_frontend_parameters dtvmultiplex_to_dvbparams(
62  DTVTunerType /*tuner_type*/, const DTVMultiplex& /*tuning*/, int intermediate_freq, bool can_fec_auto);
64  DTVTunerType /*tuner_type*/, const dvb_frontend_parameters& /*params*/);
65 
66 int64_t concurrent_tunings_delay = 1000;
67 QDateTime DVBChannel::s_lastTuning = QDateTime::currentDateTime();
68 
69 #define LOC QString("DVBChan[%1](%2): ").arg(m_inputId).arg(DVBChannel::GetDevice())
70 
76 DVBChannel::DVBChannel(QString aDevice, TVRec *parent)
77  : DTVChannel(parent), m_device(std::move(aDevice))
78 {
79  s_master_map_lock.lockForWrite();
81  if (m_pParent)
82  m_key += QString(":%1")
84 
85  s_master_map[m_key].push_back(this); // == RegisterForMaster
86  auto *master = dynamic_cast<DVBChannel*>(s_master_map[m_key].front());
87  if (master == this)
88  {
89  m_dvbCam = new DVBCam(m_device);
91  }
92  else
93  {
94  m_dvbCam = master->m_dvbCam;
95  m_hasCrcBug = master->m_hasCrcBug;
96  }
97  s_master_map_lock.unlock();
98 
100 }
101 
103 {
104  // set a new master if there are other instances and we're the master
105  // whether we are the master or not remove us from the map..
106  s_master_map_lock.lockForWrite();
107  auto *master = dynamic_cast<DVBChannel*>(s_master_map[m_key].front());
108  if (master == this)
109  {
110  s_master_map[m_key].pop_front();
111  DVBChannel *new_master = nullptr;
112  if (!s_master_map[m_key].empty())
113  new_master = dynamic_cast<DVBChannel*>(s_master_map[m_key].front());
114  if (new_master)
115  {
116  QMutexLocker master_locker(&(master->m_hwLock));
117  QMutexLocker new_master_locker(&(new_master->m_hwLock));
118  new_master->m_isOpen = master->m_isOpen;
119  }
120  }
121  else
122  {
123  s_master_map[m_key].removeAll(this);
124  }
125  s_master_map_lock.unlock();
126 
128 
129  // if we're the last one out delete dvbcam
130  s_master_map_lock.lockForRead();
131  MasterMap::iterator mit = s_master_map.find(m_key);
132  if ((*mit).empty())
133  delete m_dvbCam;
134  m_dvbCam = nullptr;
135  s_master_map_lock.unlock();
136 
137  // diseqc_tree is managed elsewhere
138 }
139 
141 {
142  LOG(VB_CHANNEL, LOG_INFO, LOC + "Closing DVB channel");
143 
144  QMutexLocker locker(&m_hwLock);
145 
146  IsOpenMap::iterator it = m_isOpen.find(who);
147  if (it == m_isOpen.end())
148  return; // this caller didn't have it open in the first place..
149 
150  m_isOpen.erase(it);
151 
152  DVBChannel *master = GetMasterLock();
153  if (master != nullptr && master != this)
154  {
155  if (m_dvbCam->IsRunning())
156  m_dvbCam->SetPMT(this, nullptr);
157  master->Close(this);
158  m_fdFrontend = -1;
159  ReturnMasterLock(master);
160  return;
161  }
162  ReturnMasterLock(master); // if we're the master we don't need this lock..
163 
164  if (!m_isOpen.empty())
165  return; // not all callers have closed the DVB channel yet..
166 
167  if (m_diseqcTree)
168  m_diseqcTree->Close();
169 
170  if (m_fdFrontend >= 0)
171  {
173  m_fdFrontend = -1;
174 
175  m_dvbCam->Stop();
176  }
177 }
178 
180 {
181  LOG(VB_CHANNEL, LOG_INFO, LOC + "Opening DVB channel");
182 
183  if (!m_inputId)
184  {
185  if (!InitializeInput())
186  return false;
187  }
188 
189  QMutexLocker locker(&m_hwLock);
190 
191  if (m_fdFrontend >= 0)
192  {
193  m_isOpen[who] = true;
194  return true;
195  }
196 
197  DVBChannel *master = GetMasterLock();
198  if (master != this)
199  {
200  if (!master->Open(who))
201  {
202  ReturnMasterLock(master);
203  return false;
204  }
205 
206  m_fdFrontend = master->m_fdFrontend;
207  m_frontendName = master->m_frontendName;
208  m_tunerType = master->m_tunerType;
209  m_capabilities = master->m_capabilities;
215 
216  m_isOpen[who] = true;
217 
218  if (!InitializeInput())
219  {
220  Close();
221  ReturnMasterLock(master);
222  return false;
223  }
224 
225  ReturnMasterLock(master);
226  return true;
227  }
228  ReturnMasterLock(master); // if we're the master we don't need this lock..
229 
231  QByteArray devn = dvbdev.toLatin1();
232 
233  for (int tries = 1; ; ++tries)
234  {
235  m_fdFrontend = open(devn.constData(), O_RDWR | O_NONBLOCK);
236  if (m_fdFrontend >= 0)
237  break;
238  LOG(VB_GENERAL, LOG_WARNING, LOC +
239  "Opening DVB frontend device failed." + ENO);
240  if (tries >= 20 || (errno != EBUSY && errno != EAGAIN))
241  {
242  LOG(VB_GENERAL, LOG_ERR, LOC +
243  QString("Failed to open DVB frontend device due to "
244  "fatal error or too many attempts."));
245  return false;
246  }
247  usleep(50000);
248  }
249 
250  dvb_frontend_info info {};
251  if (ioctl(m_fdFrontend, FE_GET_INFO, &info) < 0)
252  {
253  LOG(VB_GENERAL, LOG_ERR, LOC +
254  "Failed to get frontend information." + ENO);
255 
257  m_fdFrontend = -1;
258  return false;
259  }
260 
261  m_frontendName = info.name;
262  m_capabilities = info.caps;
263  m_frequencyMinimum = info.frequency_min;
264  m_frequencyMaximum = info.frequency_max;
265  m_symbolRateMinimum = info.symbol_rate_min;
266  m_symbolRateMaximum = info.symbol_rate_max;
267 
270 
271  LOG(VB_RECORD, LOG_INFO, LOC +
272  QString("Frontend '%2' tunertype: %3")
274 
275  // Turn on the power to the LNB
277  {
278 
280  if (m_diseqcTree)
281  {
282  bool is_SCR = false;
283 
285  if (scr)
286  {
287  is_SCR = true;
288  LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on SCR system");
289  }
290  else
291  LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on non-SCR system");
292 
293  m_diseqcTree->Open(m_fdFrontend, is_SCR);
294  }
295  }
296 
297  m_firstTune = true;
298 
299  if (!InitializeInput())
300  {
301  Close();
302  return false;
303  }
304 
305  if (m_fdFrontend >= 0)
306  m_isOpen[who] = true;
307 
308  return (m_fdFrontend >= 0);
309 }
310 
311 bool DVBChannel::IsOpen(void) const
312 {
313  // Have to acquire the hw lock to prevent is_open being modified whilst we're searching it
314  QMutexLocker locker(&m_hwLock);
315  IsOpenMap::const_iterator it = m_isOpen.find(this);
316  return it != m_isOpen.end();
317 }
318 
319 bool DVBChannel::Init(QString &startchannel, bool setchan)
320 {
321  if (setchan && !IsOpen())
322  Open(this);
323 
324  return ChannelBase::Init(startchannel, setchan);
325 }
326 
330 void DVBChannel::CheckFrequency(uint64_t frequency) const
331 {
334  (frequency < m_frequencyMinimum || frequency > m_frequencyMaximum))
335  {
336  LOG(VB_GENERAL, LOG_WARNING, LOC +
337  QString("Your frequency setting (%1) is out of range. "
338  "(min/max:%2/%3)")
340  }
341 }
342 
344 {
345  if ((tuning.m_inversion == DTVInversion::kInversionAuto) &&
346  ((m_capabilities & FE_CAN_INVERSION_AUTO) == 0U))
347  {
348  LOG(VB_GENERAL, LOG_WARNING, LOC +
349  "'Auto' inversion parameter unsupported by this driver, "
350  "falling back to 'off'.");
352  }
353 
354  // DVB-S needs a fully initialized diseqc tree and is checked later in Tune
355  if (!m_diseqcTree)
356  {
357  DVBChannel *master = GetMasterLock();
358  if (master == nullptr || !master->m_diseqcTree)
359  CheckFrequency(tuning.m_frequency);
360  ReturnMasterLock(master);
361  }
362 
363  if (m_tunerType.IsFECVariable() &&
366  (tuning.m_symbolRate < m_symbolRateMinimum ||
368  {
369  LOG(VB_GENERAL, LOG_WARNING, LOC +
370  QString("Symbol Rate setting (%1) is out of range (min/max:%2/%3)")
371  .arg(tuning.m_symbolRate)
373  }
374 
375  if (m_tunerType.IsFECVariable() && !CheckCodeRate(tuning.m_fec))
376  {
377  LOG(VB_GENERAL, LOG_WARNING, LOC +
378  "Selected fec_inner parameter unsupported by this driver.");
379  }
380 
382  {
383  LOG(VB_GENERAL, LOG_WARNING, LOC +
384  "Selected modulation parameter unsupported by this driver.");
385  }
386 
389  {
390  LOG(VB_CHANNEL, LOG_INFO, LOC + tuning.toString());
391  return;
392  }
393 
394  // Check OFDM Tuning params
395 
396  if (!CheckCodeRate(tuning.m_hpCodeRate))
397  {
398  LOG(VB_GENERAL, LOG_WARNING, LOC +
399  "Selected code_rate_hp parameter unsupported by this driver.");
400  }
401 
402  if (!CheckCodeRate(tuning.m_lpCodeRate))
403  {
404  LOG(VB_GENERAL, LOG_WARNING, LOC +
405  "Selected code_rate_lp parameter unsupported by this driver.");
406  }
407 
408  if ((tuning.m_bandwidth == DTVBandwidth::kBandwidthAuto) &&
409  ((m_capabilities & FE_CAN_BANDWIDTH_AUTO) == 0U))
410  {
411  LOG(VB_GENERAL, LOG_WARNING, LOC +
412  "'Auto' bandwidth parameter unsupported by this driver.");
413  }
414 
416  ((m_capabilities & FE_CAN_TRANSMISSION_MODE_AUTO) == 0U))
417  {
418  LOG(VB_GENERAL, LOG_WARNING, LOC +
419  "'Auto' transmission_mode parameter unsupported by this driver.");
420  }
421 
423  ((m_capabilities & FE_CAN_GUARD_INTERVAL_AUTO) == 0U))
424  {
425  LOG(VB_GENERAL, LOG_WARNING, LOC +
426  "'Auto' guard_interval parameter unsupported by this driver.");
427  }
428 
429  if ((tuning.m_hierarchy == DTVHierarchy::kHierarchyAuto) &&
430  ((m_capabilities & FE_CAN_HIERARCHY_AUTO) == 0U))
431  {
432  LOG(VB_GENERAL, LOG_WARNING, LOC +
433  "'Auto' hierarchy parameter unsupported by this driver. ");
434  }
435 
436  if (!CheckModulation(tuning.m_modulation))
437  {
438  LOG(VB_GENERAL, LOG_WARNING, LOC +
439  "Selected modulation parameter unsupported by this driver.");
440  }
441 
442  LOG(VB_CHANNEL, LOG_INFO, LOC + tuning.toString());
443 }
444 
449 {
450  const uint64_t caps = m_capabilities;
451  return
452  ((DTVCodeRate::kFECNone == rate)) ||
453  ((DTVCodeRate::kFEC_1_2 == rate) && ((caps & FE_CAN_FEC_1_2) != 0U)) ||
454  ((DTVCodeRate::kFEC_2_3 == rate) && ((caps & FE_CAN_FEC_2_3) != 0U)) ||
455  ((DTVCodeRate::kFEC_3_4 == rate) && ((caps & FE_CAN_FEC_3_4) != 0U)) ||
456  ((DTVCodeRate::kFEC_4_5 == rate) && ((caps & FE_CAN_FEC_4_5) != 0U)) ||
457  ((DTVCodeRate::kFEC_5_6 == rate) && ((caps & FE_CAN_FEC_5_6) != 0U)) ||
458  ((DTVCodeRate::kFEC_6_7 == rate) && ((caps & FE_CAN_FEC_6_7) != 0U)) ||
459  ((DTVCodeRate::kFEC_7_8 == rate) && ((caps & FE_CAN_FEC_7_8) != 0U)) ||
460  ((DTVCodeRate::kFEC_8_9 == rate) && ((caps & FE_CAN_FEC_8_9) != 0U)) ||
461  ((DTVCodeRate::kFECAuto == rate) && ((caps & FE_CAN_FEC_AUTO) != 0U));
462 }
463 
468 {
469  const DTVModulation m = modulation;
470  const uint64_t c = m_capabilities;
471 
472  return
473  ((DTVModulation::kModulationQPSK == m) && ((c & FE_CAN_QPSK) != 0U)) ||
474 #if HAVE_FE_CAN_2G_MODULATION
475  ((DTVModulation::kModulation8PSK == m) && ((c & FE_CAN_2G_MODULATION) != 0U)) ||
476  ((DTVModulation::kModulation16APSK == m) && ((c & FE_CAN_2G_MODULATION) != 0U)) ||
477  ((DTVModulation::kModulation32APSK == m) && ((c & FE_CAN_2G_MODULATION) != 0U)) ||
478 #endif //HAVE_FE_CAN_2G_MODULATION
479  ((DTVModulation::kModulationQAM16 == m) && ((c & FE_CAN_QAM_16) != 0U)) ||
480  ((DTVModulation::kModulationQAM32 == m) && ((c & FE_CAN_QAM_32) != 0U)) ||
481  ((DTVModulation::kModulationQAM64 == m) && ((c & FE_CAN_QAM_64) != 0U)) ||
482  ((DTVModulation::kModulationQAM128 == m) && ((c & FE_CAN_QAM_128) != 0U)) ||
483  ((DTVModulation::kModulationQAM256 == m) && ((c & FE_CAN_QAM_256) != 0U)) ||
484  ((DTVModulation::kModulationQAMAuto == m) && ((c & FE_CAN_QAM_AUTO) != 0U)) ||
485  ((DTVModulation::kModulation8VSB == m) && ((c & FE_CAN_8VSB) != 0U)) ||
486  ((DTVModulation::kModulation16VSB == m) && ((c & FE_CAN_16VSB) != 0U));
487 }
488 
493 {
494  if (!m_dvbCam->IsRunning())
495  m_dvbCam->Start();
496  if (pmt && m_dvbCam->IsRunning())
497  m_dvbCam->SetPMT(this, pmt);
498 }
499 
504 void DVBChannel::SetTimeOffset(double offset)
505 {
506  if (m_dvbCam->IsRunning())
507  m_dvbCam->SetTimeOffset(offset);
508 }
509 
510 bool DVBChannel::Tune(const DTVMultiplex &tuning)
511 {
512  if (!m_inputId)
513  {
514  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Tune(): Invalid input."));
515  return false;
516  }
517  return Tune(tuning, false, false);
518 }
519 
520 static struct dtv_properties *dtvmultiplex_to_dtvproperties(
521  DTVTunerType tuner_type, const DTVMultiplex &tuning, int intermediate_freq,
522  bool can_fec_auto, bool do_tune = true)
523 {
524  uint c = 0;
525 
526  if (tuner_type != DTVTunerType::kTunerTypeDVBT &&
527  tuner_type != DTVTunerType::kTunerTypeDVBC &&
528  tuner_type != DTVTunerType::kTunerTypeDVBS1 &&
529  tuner_type != DTVTunerType::kTunerTypeDVBS2 &&
530  tuner_type != DTVTunerType::kTunerTypeDVBT2)
531  {
532  LOG(VB_GENERAL, LOG_ERR, "DVBChan: Unsupported tuner type " +
533  tuner_type.toString());
534  return nullptr;
535  }
536 
537  LOG(VB_CHANNEL, LOG_DEBUG, "DVBChan: modsys " + tuning.m_modSys.toString());
538 
539  auto *cmdseq = (struct dtv_properties*) calloc(1, sizeof(struct dtv_properties));
540  if (!cmdseq)
541  return nullptr;
542 
543  cmdseq->props = (struct dtv_property*) calloc(20, sizeof(*(cmdseq->props)));
544  if (!(cmdseq->props))
545  {
546  free(cmdseq);
547  return nullptr;
548  }
549 
550  // The cx24116 DVB-S2 demod anounce FE_CAN_FEC_AUTO but has apparently
551  // trouble with FEC_AUTO on DVB-S2 transponders
553  can_fec_auto = false;
554 
555  if (tuner_type == DTVTunerType::kTunerTypeDVBS2 ||
556  tuner_type == DTVTunerType::kTunerTypeDVBT ||
557  tuner_type == DTVTunerType::kTunerTypeDVBT2)
558  {
559  cmdseq->props[c].cmd = DTV_DELIVERY_SYSTEM;
560  cmdseq->props[c++].u.data = tuning.m_modSys;
561  }
562 
563  cmdseq->props[c].cmd = DTV_FREQUENCY;
564  cmdseq->props[c++].u.data = intermediate_freq ? intermediate_freq : tuning.m_frequency;
565  cmdseq->props[c].cmd = DTV_MODULATION;
566  cmdseq->props[c++].u.data = tuning.m_modulation;
567  cmdseq->props[c].cmd = DTV_INVERSION;
568  cmdseq->props[c++].u.data = tuning.m_inversion;
569 
570  if (tuner_type == DTVTunerType::kTunerTypeDVBS1 ||
571  tuner_type == DTVTunerType::kTunerTypeDVBS2 ||
572  tuner_type == DTVTunerType::kTunerTypeDVBC)
573  {
574  cmdseq->props[c].cmd = DTV_SYMBOL_RATE;
575  cmdseq->props[c++].u.data = tuning.m_symbolRate;
576  }
577 
578  if (tuner_type.IsFECVariable())
579  {
580  cmdseq->props[c].cmd = DTV_INNER_FEC;
581  cmdseq->props[c++].u.data = can_fec_auto ? FEC_AUTO
582  : (fe_code_rate_t) (int) tuning.m_fec;
583  }
584 
585  if (tuner_type == DTVTunerType::kTunerTypeDVBT ||
586  tuner_type == DTVTunerType::kTunerTypeDVBT2)
587  {
588  cmdseq->props[c].cmd = DTV_BANDWIDTH_HZ;
589  cmdseq->props[c++].u.data = (8-tuning.m_bandwidth) * 1000000;
590  cmdseq->props[c].cmd = DTV_CODE_RATE_HP;
591  cmdseq->props[c++].u.data = tuning.m_hpCodeRate;
592  cmdseq->props[c].cmd = DTV_CODE_RATE_LP;
593  cmdseq->props[c++].u.data = tuning.m_lpCodeRate;
594  cmdseq->props[c].cmd = DTV_TRANSMISSION_MODE;
595  cmdseq->props[c++].u.data = tuning.m_transMode;
596  cmdseq->props[c].cmd = DTV_GUARD_INTERVAL;
597  cmdseq->props[c++].u.data = tuning.m_guardInterval;
598  cmdseq->props[c].cmd = DTV_HIERARCHY;
599  cmdseq->props[c++].u.data = tuning.m_hierarchy;
600  }
601 
603  {
604  cmdseq->props[c].cmd = DTV_PILOT;
605  cmdseq->props[c++].u.data = PILOT_AUTO;
606  cmdseq->props[c].cmd = DTV_ROLLOFF;
607  cmdseq->props[c++].u.data = tuning.m_rolloff;
608  }
610  {
611  cmdseq->props[c].cmd = DTV_ROLLOFF;
612  cmdseq->props[c++].u.data = DTVRollOff::kRollOff_35;
613  }
614 
615  if (do_tune)
616  cmdseq->props[c++].cmd = DTV_TUNE;
617 
618  cmdseq->num = c;
619 
620  return cmdseq;
621 }
622 
623 /*****************************************************************************
624  Tuning functions for each of the five types of cards.
625  *****************************************************************************/
626 
638 bool DVBChannel::Tune(const DTVMultiplex &tuning,
639  bool force_reset,
640  bool same_input)
641 {
642  QMutexLocker lock(&m_tuneLock);
643  QMutexLocker locker(&m_hwLock);
644 
645  DVBChannel *master = GetMasterLock();
646  if (master != this)
647  {
648  LOG(VB_CHANNEL, LOG_INFO, LOC + "Tuning on slave channel");
649  SetSIStandard(tuning.m_sistandard);
650  bool ok = master->Tune(tuning, force_reset, false);
651  ReturnMasterLock(master);
652  return ok;
653  }
654  ReturnMasterLock(master); // if we're the master we don't need this lock..
655 
656 
657  int intermediate_freq = 0;
658  bool can_fec_auto = false;
659  bool reset = (force_reset || m_firstTune);
660 
662  {
663  LOG(VB_GENERAL, LOG_ERR, LOC +
664  "DVB-S/S2 needs device tree for LNB handling");
665  return false;
666  }
667 
668  m_desiredTuning = tuning;
669 
670  if (m_fdFrontend < 0)
671  {
672  LOG(VB_GENERAL, LOG_ERR, LOC + "Tune(): Card not open!");
673 
674  return false;
675  }
676 
677  // Remove any events in queue before tuning.
679 
680  LOG(VB_CHANNEL, LOG_INFO, LOC + "\nOld Params: " + m_prevTuning.toString() +
681  "\nNew Params: " + tuning.toString());
682 
683  // DVB-S is in kHz, other DVB is in Hz
684  bool is_dvbs = ((DTVTunerType::kTunerTypeDVBS1 == m_tunerType) ||
686  int freq_mult = (is_dvbs) ? 1 : 1000;
687  QString suffix = (is_dvbs) ? "kHz" : "Hz";
688 
689  if (reset || !m_prevTuning.IsEqual(m_tunerType, tuning, 500 * freq_mult))
690  {
691  LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(): Tuning to %1%2")
692  .arg(intermediate_freq ? intermediate_freq : tuning.m_frequency)
693  .arg(suffix));
694 
695  m_tuneDelayLock.lock();
696 
697  if (QDateTime::currentDateTime() < s_lastTuning)
698  {
699  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Next tuning after less than %1ms. Delaying by %1ms")
701  usleep(concurrent_tunings_delay * 1000);
702  }
703 
704  s_lastTuning = QDateTime::currentDateTime();
706 
707  m_tuneDelayLock.unlock();
708 
709  // send DVB-S setup
710  if (m_diseqcTree)
711  {
712  // configure for new input
713  if (!same_input)
715 
716  // execute diseqc commands
717  if (!m_diseqcTree->Execute(m_diseqcSettings, tuning))
718  {
719  LOG(VB_GENERAL, LOG_ERR, LOC +
720  "Tune(): Failed to setup DiSEqC devices");
721  return false;
722  }
723 
724  // retrieve actual intermediate frequency
726  if (!lnb)
727  {
728  LOG(VB_GENERAL, LOG_ERR, LOC +
729  "Tune(): No LNB for this configuration");
730  return false;
731  }
732 
733  if (lnb->GetDeviceID() != m_lastLnbDevId)
734  {
735  m_lastLnbDevId = lnb->GetDeviceID();
736  // make sure we tune to frequency, if the lnb has changed
737  m_firstTune = true;
738  }
739 
740  intermediate_freq = lnb->GetIntermediateFrequency(
741  m_diseqcSettings, tuning);
742 
743  // retrieve scr intermediate frequency
745  if (lnb && scr)
746  {
747  intermediate_freq = scr->GetIntermediateFrequency(intermediate_freq);
748  }
749 
750  // if card can auto-FEC, use it -- sometimes NITs are inaccurate
751  if (m_capabilities & FE_CAN_FEC_AUTO)
752  can_fec_auto = true;
753 
754  // Check DVB-S intermediate frequency here since it requires a fully
755  // initialized diseqc tree
756  CheckFrequency(intermediate_freq);
757  }
758 
761  {
762  struct dtv_property p_clear = {};
763  struct dtv_properties cmdseq_clear = {};
764 
765  p_clear.cmd = DTV_CLEAR;
766  cmdseq_clear.num = 1;
767  cmdseq_clear.props = &p_clear;
768 
769  if ((ioctl(m_fdFrontend, FE_SET_PROPERTY, &cmdseq_clear)) < 0)
770  {
771  LOG(VB_GENERAL, LOG_ERR, LOC +
772  "Tune(): Clearing DTV properties cache failed." + ENO);
773  return false;
774  }
775 
776  struct dtv_properties *cmds = dtvmultiplex_to_dtvproperties(
777  m_tunerType, tuning, intermediate_freq, can_fec_auto);
778 
779  if (!cmds) {
780  LOG(VB_GENERAL, LOG_ERR, LOC +
781  "Failed to convert DTVMultiplex to DTV_PROPERTY sequence");
782  return false;
783  }
784 
785  if (VERBOSE_LEVEL_CHECK(VB_CHANNEL, LOG_DEBUG))
786  {
787  for (uint i = 0; i < cmds->num; i++)
788  {
789  LOG(VB_CHANNEL, LOG_DEBUG, LOC +
790  QString("prop %1: cmd = %2, data %3")
791  .arg(i).arg(cmds->props[i].cmd)
792  .arg(cmds->props[i].u.data));
793  }
794  }
795 
796  int res = ioctl(m_fdFrontend, FE_SET_PROPERTY, cmds);
797 
798  free(cmds->props);
799  free(cmds);
800 
801  if (res < 0)
802  {
803  LOG(VB_GENERAL, LOG_ERR, LOC +
804  "Tune(): Setting Frontend tuning parameters failed." + ENO);
805  return false;
806  }
807  }
808  else
809  {
810  struct dvb_frontend_parameters params = dtvmultiplex_to_dvbparams(
811  m_tunerType, tuning, intermediate_freq, can_fec_auto);
812 
813  if (ioctl(m_fdFrontend, FE_SET_FRONTEND, &params) < 0)
814  {
815  LOG(VB_GENERAL, LOG_ERR, LOC +
816  "Tune(): Setting Frontend tuning parameters failed." + ENO);
817  return false;
818  }
819  }
820 
821  // Extra delay to add for broken DVB drivers
822  if (m_tuningDelay)
823  usleep(m_tuningDelay * 1000);
824 
825  wait_for_backend(m_fdFrontend, 50 /* msec */);
826 
827  m_prevTuning = tuning;
828  m_firstTune = false;
829  }
830 
831  SetSIStandard(tuning.m_sistandard);
832 
833  LOG(VB_CHANNEL, LOG_INFO, LOC + "Tune(): Frequency tuning successful");
834 
835  return true;
836 }
837 
839 {
840  return Tune(m_desiredTuning, true, true);
841 }
842 
847 {
848  QMutexLocker locker(&m_hwLock);
849 
850  if (m_fdFrontend < 0)
851  {
852  LOG(VB_GENERAL, LOG_ERR, LOC + "Card not open!");
853 
854  return false;
855  }
856 
857  DVBChannel *master = GetMasterLock();
858  if (master != this)
859  {
860  bool ok = master->IsTuningParamsProbeSupported();
861  ReturnMasterLock(master);
862  return ok;
863  }
864  ReturnMasterLock(master); // if we're the master we don't need this lock..
865 
866  if (m_diseqcTree)
867  {
868  // TODO We need to implement the inverse of
869  // lnb->GetIntermediateFrequency() for ProbeTuningParams()
870  // to accurately reflect the frequency before LNB transform.
871  return false;
872  }
873 
874  dvb_frontend_parameters params {};
875 
876  int res = ioctl(m_fdFrontend, FE_GET_FRONTEND, &params);
877  if (res < 0)
878  {
879  LOG(VB_CHANNEL, LOG_ERR, LOC + "Getting device frontend failed." + ENO);
880  }
881 
882  return (res >= 0);
883 }
884 
893 {
894  QMutexLocker locker(&m_hwLock);
895 
896  if (m_fdFrontend < 0)
897  {
898  LOG(VB_GENERAL, LOG_ERR, LOC + "Card not open!");
899 
900  return false;
901  }
902 
903  DVBChannel *master = GetMasterLock();
904  if (master != this)
905  {
906  bool ok = master->ProbeTuningParams(tuning);
907  ReturnMasterLock(master);
908  return ok;
909  }
910  ReturnMasterLock(master); // if we're the master we don't need this lock..
911 
912  if (m_diseqcTree)
913  {
914  // TODO We need to implement the inverse of
915  // lnb->GetIntermediateFrequency() for ProbeTuningParams()
916  // to accurately reflect the frequency before LNB transform.
917  return false;
918  }
919 
921  {
922  // TODO implement probing of tuning parameters with FE_GET_PROPERTY
923  return false;
924  }
925 
926  dvb_frontend_parameters params {};
927  if (ioctl(m_fdFrontend, FE_GET_FRONTEND, &params) < 0)
928  {
929  LOG(VB_GENERAL, LOG_ERR, LOC +
930  "Getting Frontend tuning parameters failed." + ENO);
931 
932  return false;
933  }
934 
935  uint mplex = tuning.m_mplex;
936  QString sistandard = tuning.m_sistandard;
937 
938  tuning = dvbparams_to_dtvmultiplex(m_tunerType, params);
939 
940  tuning.m_mplex = mplex;
941  tuning.m_sistandard = sistandard;
942 
943  return true;
944 }
945 
951 {
952  int found = 0;
953  int id = -1;
955 
956  query.prepare("SELECT chanid,visible "
957  "FROM channel, capturecard "
958  "WHERE channel.deleted IS NULL AND "
959  " capturecard.sourceid = channel.sourceid AND "
960  " channel.channum = :CHANNUM AND "
961  " capturecard.cardid = :INPUTID");
962 
963  query.bindValue(":CHANNUM", m_curChannelName);
964  query.bindValue(":INPUTID", m_inputId);
965 
966  if (!query.exec() || !query.isActive())
967  {
968  MythDB::DBError("fetching chanid", query);
969  return -1;
970  }
971 
972  while (query.next())
973  {
974  found += static_cast<int>(query.value(1).toInt() > 0);
975  if (id == -1 || found)
976  id = query.value(0).toInt();
977  }
978 
979  if (!found)
980  {
981  LOG(VB_GENERAL, LOG_INFO,
982  QString("No visible channel ids for %1")
984  }
985 
986  if (found > 1)
987  {
988  LOG(VB_GENERAL, LOG_WARNING,
989  QString("Found multiple visible channel ids for %1")
991  }
992 
993  return id;
994 }
995 
997 {
998  if (m_diseqcTree)
1000 
1001  return nullptr;
1002 }
1003 
1004 // documented in dvbchannel.h
1005 bool DVBChannel::HasLock(bool *ok) const
1006 {
1007  DVBChannel *master = GetMasterLock();
1008  if (master != this)
1009  {
1010  bool haslock = master->HasLock(ok);
1011  ReturnMasterLock(master);
1012  return haslock;
1013  }
1014  ReturnMasterLock(master); // if we're the master we don't need this lock..
1015 
1016 #if ((DVB_API_VERSION > 5) || ((DVB_API_VERSION == 5) && (DVB_API_VERSION_MINOR > 10)))
1017  fe_status_t status = FE_NONE;
1018 #else // debian9, centos7
1019  fe_status_t status = (fe_status_t)0;
1020 #endif
1021  memset(&status, 0, sizeof(status));
1022 
1023  int ret = ioctl(m_fdFrontend, FE_READ_STATUS, &status);
1024  if (ret < 0)
1025  {
1026  LOG(VB_GENERAL, LOG_ERR, LOC +
1027  "FE_READ_STATUS failed" + ENO);
1028  }
1029 
1030  if (ok)
1031  *ok = (0 == ret);
1032 
1033  return (status & FE_HAS_LOCK) != 0;
1034 }
1035 
1036 // documented in dvbchannel.h
1038 {
1039  struct dtv_property prop = {};
1040  struct dtv_properties cmd = {};
1041 
1042  prop.cmd = DTV_STAT_SIGNAL_STRENGTH;
1043  cmd.num = 1;
1044  cmd.props = &prop;
1045  int ret = ioctl(m_fdFrontend, FE_GET_PROPERTY, &cmd);
1046  LOG(VB_RECORD, LOG_DEBUG, LOC +
1047  QString("FE DTV signal strength ret=%1 res=%2 len=%3 scale=%4 val=%5")
1048  .arg(ret)
1049  .arg(cmd.props->result)
1050  .arg(cmd.props->u.st.len)
1051  .arg(cmd.props->u.st.stat[0].scale)
1052  .arg(cmd.props->u.st.stat[0].svalue)
1053  );
1054  bool tmpOk = (ret == 0) && (cmd.props->u.st.len > 0);
1055  if (ok)
1056  *ok = tmpOk;
1057  double value = 0;
1058  if (tmpOk)
1059  {
1060  if (cmd.props->u.st.stat[0].scale == FE_SCALE_DECIBEL)
1061  {
1062  // -20dBm is a great signal so make that 100%
1063  // -100dBm lower than the noise floor so that is 0%
1064  // svalue is in 0.001 dBm
1065  // If the value is outside the range -100 to 0 dBm
1066  // we do not believe it.
1067  int svalue = cmd.props->u.st.stat[0].svalue;
1068  if (svalue >= -100000 && svalue <= -0)
1069  {
1070  // convert value from -100dBm to -20dBm to a 0-1 range
1071  value = svalue + 100000.0;
1072  value = value / 80000.0;
1073  if (value > 1.0)
1074  value = 1.0;
1075  }
1076  }
1077  else if (cmd.props->u.st.stat[0].scale == FE_SCALE_RELATIVE)
1078  {
1079  // returned as 16 bit unsigned
1080  value = cmd.props->u.st.stat[0].uvalue / 65535.0;
1081  }
1082  }
1083  else
1084  {
1085  LOG(VB_RECORD, LOG_ERR, LOC +
1086  "Getting DVBv5 Frontend signal strength failed." + ENO);
1087  }
1088  return value;
1089 }
1090 
1091 // documented in dvbchannel.h
1092 double DVBChannel::GetSignalStrength(bool *ok) const
1093 {
1094  DVBChannel *master = GetMasterLock();
1095  if (master != this)
1096  {
1097  double val = master->GetSignalStrength(ok);
1098  ReturnMasterLock(master);
1099  return val;
1100  }
1101  ReturnMasterLock(master); // if we're the master we don't need this lock..
1102 
1103  // We use uint16_t for sig because this is correct for DVB API 4.0,
1104  // and works better than the correct int16_t for the 3.x API
1105  uint16_t sig = 0;
1106  int ret = ioctl(m_fdFrontend, FE_READ_SIGNAL_STRENGTH, &sig);
1107  if (ret < 0)
1108  {
1109  if (errno == EOPNOTSUPP || errno == ENOTSUPP)
1110  {
1111  return GetSignalStrengthDVBv5(ok);
1112  }
1113  LOG(VB_RECORD, LOG_ERR, LOC +
1114  "Getting Frontend signal strength failed." + ENO);
1115  }
1116 
1117  if (ok)
1118  *ok = (0 == ret);
1119 
1120  return sig * (1.0 / 65535.0);
1121 }
1122 
1123 // documented in dvbchannel.h
1124 double DVBChannel::GetSNRDVBv5(bool *ok) const
1125 {
1126  struct dtv_property prop = {};
1127  struct dtv_properties cmd = {};
1128 
1129  memset(&prop, 0, sizeof(prop));
1130  prop.cmd = DTV_STAT_CNR;
1131  cmd.num = 1;
1132  cmd.props = &prop;
1133  int ret = ioctl(m_fdFrontend, FE_GET_PROPERTY, &cmd);
1134  LOG(VB_RECORD, LOG_DEBUG, LOC +
1135  QString("FE DTV cnr ret=%1 res=%2 len=%3 scale=%4 val=%5")
1136  .arg(ret)
1137  .arg(cmd.props->result)
1138  .arg(cmd.props->u.st.len)
1139  .arg(cmd.props->u.st.stat[0].scale)
1140  .arg(cmd.props->u.st.stat[0].svalue)
1141  );
1142  bool tmpOk = (ret == 0) && (cmd.props->u.st.len > 0);
1143  if (ok)
1144  *ok = tmpOk;
1145  double value = 0;
1146  if (tmpOk)
1147  {
1148  if (cmd.props->u.st.stat[0].scale == FE_SCALE_DECIBEL)
1149  {
1150  // svalue is in 0.001 dB
1151  value = cmd.props->u.st.stat[0].svalue;
1152  // let 50dB+ CNR be 100% quality and 0dB be 0%
1153  // convert 0.001 dB from 0-50000 to a 0-1 range
1154  value = value / 50000.0;
1155  if (value > 1.0)
1156  value = 1.0;
1157  else if (value < 0)
1158  value = 0.0;
1159  }
1160  else if (cmd.props->u.st.stat[0].scale == FE_SCALE_RELATIVE)
1161  {
1162  // returned as 16 bit unsigned
1163  value = cmd.props->u.st.stat[0].uvalue / 65535.0;
1164  }
1165  }
1166  else
1167  {
1168  LOG(VB_RECORD, LOG_ERR, LOC +
1169  "Getting DVBv5 Frontend signal/noise ratio failed." + ENO);
1170  }
1171  return value;
1172 }
1173 
1174 // documented in dvbchannel.h
1175 double DVBChannel::GetSNR(bool *ok) const
1176 {
1177  DVBChannel *master = GetMasterLock();
1178  if (master != this)
1179  {
1180  double val = master->GetSNR(ok);
1181  ReturnMasterLock(master);
1182  return val;
1183  }
1184  ReturnMasterLock(master); // if we're the master we don't need this lock..
1185 
1186  // We use uint16_t for sig because this is correct for DVB API 4.0,
1187  // and works better than the correct int16_t for the 3.x API
1188  uint16_t snr = 0;
1189  int ret = ioctl(m_fdFrontend, FE_READ_SNR, &snr);
1190  if (ret < 0)
1191  {
1192  if (errno == EOPNOTSUPP || errno == ENOTSUPP)
1193  {
1194  return GetSNRDVBv5(ok);
1195  }
1196  LOG(VB_GENERAL, LOG_ERR, LOC +
1197  "Getting Frontend signal/noise ratio failed." + ENO);
1198  }
1199 
1200  if (ok)
1201  *ok = (0 == ret);
1202 
1203  return snr * (1.0 / 65535.0);
1204 }
1205 
1206 // documented in dvbchannel.h
1207 double DVBChannel::GetBitErrorRateDVBv5(bool *ok) const
1208 {
1209  struct dtv_property prop[2] = {};
1210  struct dtv_properties cmd = {};
1211 
1212  prop[0].cmd = DTV_STAT_POST_ERROR_BIT_COUNT;
1213  prop[1].cmd = DTV_STAT_POST_TOTAL_BIT_COUNT;
1214  cmd.num = 2;
1215  cmd.props = prop;
1216  int ret = ioctl(m_fdFrontend, FE_GET_PROPERTY, &cmd);
1217  LOG(VB_RECORD, LOG_DEBUG, LOC +
1218  QString("FE DTV bit error rate ret=%1 res=%2 len=%3 scale=%4 val=%5 res=%6 len=%7 scale=%8 val=%9")
1219  .arg(ret)
1220  .arg(cmd.props[0].result)
1221  .arg(cmd.props[0].u.st.len)
1222  .arg(cmd.props[0].u.st.stat[0].scale)
1223  .arg(cmd.props[0].u.st.stat[0].uvalue)
1224  .arg(cmd.props[1].result)
1225  .arg(cmd.props[1].u.st.len)
1226  .arg(cmd.props[1].u.st.stat[0].scale)
1227  .arg(cmd.props[1].u.st.stat[0].uvalue)
1228  );
1229  bool tmpOk = (ret == 0) &&
1230  (cmd.props[0].u.st.len > 0) &&
1231  (cmd.props[1].u.st.len > 0);
1232  if (ok)
1233  *ok = tmpOk;
1234  double value = 0;
1235  if (tmpOk)
1236  {
1237  if ((cmd.props[0].u.st.stat[0].scale == FE_SCALE_COUNTER) &&
1238  (cmd.props[1].u.st.stat[0].scale == FE_SCALE_COUNTER) &&
1239  (cmd.props[1].u.st.stat[0].uvalue != 0))
1240  {
1241  value = static_cast<double>(
1242  static_cast<long double>(cmd.props[0].u.st.stat[0].uvalue) /
1243  cmd.props[1].u.st.stat[0].uvalue);
1244  }
1245  }
1246  else
1247  {
1248  LOG(VB_RECORD, LOG_ERR, LOC +
1249  "Getting DVBv5 Frontend bit error rate failed." + ENO);
1250  }
1251  return value;
1252 }
1253 
1254 // documented in dvbchannel.h
1255 double DVBChannel::GetBitErrorRate(bool *ok) const
1256 {
1257  DVBChannel *master = GetMasterLock();
1258  if (master != this)
1259  {
1260  double val = master->GetBitErrorRate(ok);
1261  ReturnMasterLock(master);
1262  return val;
1263  }
1264  ReturnMasterLock(master); // if we're the master we don't need this lock..
1265 
1266  uint32_t ber = 0;
1267  int ret = ioctl(m_fdFrontend, FE_READ_BER, &ber);
1268  if (ret < 0)
1269  {
1270  if (errno == EOPNOTSUPP || errno == ENOTSUPP)
1271  {
1272  return GetBitErrorRateDVBv5(ok);
1273  }
1274  LOG(VB_RECORD, LOG_ERR, LOC +
1275  "Getting Frontend bit error rate failed." + ENO);
1276  }
1277 
1278  if (ok)
1279  *ok = (0 == ret);
1280 
1281  return (double) ber;
1282 }
1283 
1284 // documented in dvbchannel.h
1286 {
1287  struct dtv_property prop = {};
1288  struct dtv_properties cmd = {};
1289 
1290  prop.cmd = DTV_STAT_ERROR_BLOCK_COUNT;
1291  cmd.num = 1;
1292  cmd.props = &prop;
1293  int ret = ioctl(m_fdFrontend, FE_GET_PROPERTY, &cmd);
1294  LOG(VB_RECORD, LOG_DEBUG, LOC +
1295  QString("FE DTV uncorrected block count ret=%1 res=%2 len=%3 scale=%4 val=%5")
1296  .arg(ret)
1297  .arg(cmd.props[0].result)
1298  .arg(cmd.props[0].u.st.len)
1299  .arg(cmd.props[0].u.st.stat[0].scale)
1300  .arg(cmd.props[0].u.st.stat[0].svalue)
1301  );
1302  bool tmpOk = (ret == 0) && (cmd.props->u.st.len > 0);
1303  if (ok)
1304  *ok = tmpOk;
1305  double value = 0;
1306  if (tmpOk)
1307  {
1308  if (cmd.props->u.st.stat[0].scale == FE_SCALE_COUNTER)
1309  value = cmd.props->u.st.stat[0].uvalue;
1310  }
1311  else
1312  {
1313  LOG(VB_RECORD, LOG_DEBUG, LOC +
1314  "Getting DVBv5 Frontend uncorrected block count failed." + ENO);
1315  }
1316  return value;
1317 }
1318 
1319 // documented in dvbchannel.h
1321 {
1322  DVBChannel *master = GetMasterLock();
1323  if (master != this)
1324  {
1325  double val = master->GetUncorrectedBlockCount(ok);
1326  ReturnMasterLock(master);
1327  return val;
1328  }
1329  ReturnMasterLock(master); // if we're the master we don't need this lock..
1330 
1331  uint32_t ublocks = 0;
1332  int ret = ioctl(m_fdFrontend, FE_READ_UNCORRECTED_BLOCKS, &ublocks);
1333  if (ret < 0)
1334  {
1335  if (errno == EOPNOTSUPP || errno == ENOTSUPP)
1336  {
1337  return GetUncorrectedBlockCountDVBv5(ok);
1338  }
1339  LOG(VB_GENERAL, LOG_ERR, LOC +
1340  "Getting Frontend uncorrected block count failed." + ENO);
1341  }
1342 
1343  if (ok)
1344  *ok = (0 == ret);
1345 
1346  return (double) ublocks;
1347 }
1348 
1350 {
1351  auto *chan = static_cast<DTVChannel*>(dvbm);
1353  dvbm = nullptr;
1354 }
1355 
1357 {
1359  auto *dvbm = dynamic_cast<DVBChannel*>(master);
1360  if (master && !dvbm)
1362  return dvbm;
1363 }
1364 
1365 bool DVBChannel::IsMaster(void) const
1366 {
1367  DVBChannel *master = GetMasterLock();
1368  bool is_master = (master == this);
1369  ReturnMasterLock(master);
1370  return is_master;
1371 }
1372 
1377 static void drain_dvb_events(int fd)
1378 {
1379  struct dvb_frontend_event event {};
1380  int ret = 0;
1381  while ((ret = ioctl(fd, FE_GET_EVENT, &event)) == 0);
1382  if ((ret < 0) && (EAGAIN != errno))
1383  {
1384  LOG(VB_CHANNEL, LOG_DEBUG, "Draining DVB Event failed. " + ENO);
1385  }
1386 }
1387 
1411 static bool wait_for_backend(int fd, int timeout_ms)
1412 {
1413  struct timeval select_timeout = { timeout_ms/1000, (timeout_ms % 1000) * 1000 /*usec*/};
1414  fd_set fd_select_set;
1415  FD_ZERO( &fd_select_set); // NOLINT(readability-isolate-declaration)
1416  FD_SET (fd, &fd_select_set);
1417 
1418  // Try to wait for some output like an event, unfortunately
1419  // this fails on several DVB cards, so we have a timeout.
1420  int ret = 0;
1421  do ret = select(fd+1, &fd_select_set, nullptr, nullptr, &select_timeout);
1422  while ((-1 == ret) && (EINTR == errno));
1423 
1424  if (-1 == ret)
1425  {
1426  LOG(VB_GENERAL, LOG_ERR,
1427  "DVBChan: wait_for_backend: Failed to wait on output" + ENO);
1428 
1429  return false;
1430  }
1431 
1432  // This is supposed to work on all cards, post 2.6.12...
1433 #if ((DVB_API_VERSION > 5) || ((DVB_API_VERSION == 5) && (DVB_API_VERSION_MINOR > 10)))
1434  fe_status_t status = FE_NONE;
1435 #else // debian9, centos7
1436  fe_status_t status = (fe_status_t)0;
1437 #endif
1438  memset(&status, 0, sizeof(status));
1439 
1440  if (ioctl(fd, FE_READ_STATUS, &status) < 0)
1441  {
1442  LOG(VB_GENERAL, LOG_ERR,
1443  "DVBChan: wait_for_backend: Failed to get status" + ENO);
1444 
1445  return false;
1446  }
1447 
1448  LOG(VB_CHANNEL, LOG_INFO, QString("DVBChan: wait_for_backend: Status: %1")
1449  .arg(toString(status)));
1450 
1451  return true;
1452 }
1453 
1454 static struct dvb_frontend_parameters dtvmultiplex_to_dvbparams(
1455  DTVTunerType tuner_type, const DTVMultiplex &tuning,
1456  int intermediate_freq, bool can_fec_auto)
1457 {
1458  dvb_frontend_parameters params {};
1459 
1460  params.frequency = tuning.m_frequency;
1461  params.inversion = (fe_spectral_inversion_t) (int) tuning.m_inversion;
1462 
1463  if (DTVTunerType::kTunerTypeDVBS1 == tuner_type)
1464  {
1465  if (tuning.m_modSys == DTVModulationSystem::kModulationSystem_DVBS2)
1466  {
1467  LOG(VB_GENERAL, LOG_ERR,
1468  "DVBChan: Error, Tuning of a DVB-S2 transport "
1469  "with a DVB-S card will fail.");
1470  }
1471 
1472  params.frequency = intermediate_freq;
1473  params.u.qpsk.symbol_rate = tuning.m_symbolRate;
1474  params.u.qpsk.fec_inner = can_fec_auto ? FEC_AUTO
1475  : (fe_code_rate_t) (int) tuning.m_fec;
1476  }
1477 
1478  if (DTVTunerType::kTunerTypeDVBS2 == tuner_type)
1479  {
1480  LOG(VB_GENERAL, LOG_ERR,
1481  "DVBChan: Error, MythTV was compiled without "
1482  "DVB-S2 headers being present so DVB-S2 tuning will fail.");
1483  }
1484 
1485  if (DTVTunerType::kTunerTypeDVBC == tuner_type)
1486  {
1487  params.u.qam.symbol_rate = tuning.m_symbolRate;
1488  params.u.qam.fec_inner = (fe_code_rate_t) (int) tuning.m_fec;
1489  params.u.qam.modulation = (fe_modulation_t) (int) tuning.m_modulation;
1490  }
1491 
1492  if (DTVTunerType::kTunerTypeDVBT == tuner_type ||
1493  DTVTunerType::kTunerTypeDVBT2 == tuner_type)
1494  {
1495  params.u.ofdm.bandwidth =
1496  (fe_bandwidth_t) (int) tuning.m_bandwidth;
1497  params.u.ofdm.code_rate_HP =
1498  (fe_code_rate_t) (int) tuning.m_hpCodeRate;
1499  params.u.ofdm.code_rate_LP =
1500  (fe_code_rate_t) (int) tuning.m_lpCodeRate;
1501  params.u.ofdm.constellation =
1502  (fe_modulation_t) (int) tuning.m_modulation;
1503  params.u.ofdm.transmission_mode =
1504  (fe_transmit_mode_t) (int) tuning.m_transMode;
1505  params.u.ofdm.guard_interval =
1506  (fe_guard_interval_t) (int) tuning.m_guardInterval;
1507  params.u.ofdm.hierarchy_information =
1508  (fe_hierarchy_t) (int) tuning.m_hierarchy;
1509  }
1510 
1511  if (DTVTunerType::kTunerTypeATSC == tuner_type)
1512  {
1513  params.u.vsb.modulation =
1514  (fe_modulation_t) (int) tuning.m_modulation;
1515  }
1516 
1517  return params;
1518 }
1519 
1521  DTVTunerType tuner_type, const dvb_frontend_parameters &params)
1522 {
1523  DTVMultiplex tuning;
1524 
1525  tuning.m_frequency = params.frequency;
1526  tuning.m_inversion = params.inversion;
1527 
1528  if ((DTVTunerType::kTunerTypeDVBS1 == tuner_type) ||
1529  (DTVTunerType::kTunerTypeDVBS2 == tuner_type))
1530  {
1531  tuning.m_symbolRate = params.u.qpsk.symbol_rate;
1532  tuning.m_fec = params.u.qpsk.fec_inner;
1533  }
1534 
1535  if (DTVTunerType::kTunerTypeDVBC == tuner_type)
1536  {
1537  tuning.m_symbolRate = params.u.qam.symbol_rate;
1538  tuning.m_fec = params.u.qam.fec_inner;
1539  tuning.m_modulation = params.u.qam.modulation;
1540  }
1541 
1542  if (DTVTunerType::kTunerTypeDVBT == tuner_type ||
1543  DTVTunerType::kTunerTypeDVBT2 == tuner_type)
1544  {
1545  tuning.m_bandwidth = params.u.ofdm.bandwidth;
1546  tuning.m_hpCodeRate = params.u.ofdm.code_rate_HP;
1547  tuning.m_lpCodeRate = params.u.ofdm.code_rate_LP;
1548  tuning.m_modulation = params.u.ofdm.constellation;
1549  tuning.m_transMode = params.u.ofdm.transmission_mode;
1550  tuning.m_guardInterval = params.u.ofdm.guard_interval;
1551  tuning.m_hierarchy = params.u.ofdm.hierarchy_information;
1552  }
1553 
1554  if (DTVTunerType::kTunerTypeATSC == tuner_type)
1555  {
1556  tuning.m_modulation = params.u.vsb.modulation;
1557  }
1558 
1559  return tuning;
1560 }
DTVMultiplex::m_frequency
uint64_t m_frequency
Definition: dtvmultiplex.h:94
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:204
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
DVBChannel::CheckModulation
bool CheckModulation(DTVModulation modulation) const
Return true iff modulation is supported modulation on the frontend.
Definition: dvbchannel.cpp:467
DTVMultiplex
Definition: dtvmultiplex.h:25
DVBChannel::GetUncorrectedBlockCount
double GetUncorrectedBlockCount(bool *ok=nullptr) const
Returns # of uncorrected blocks since last call. First call undefined.
Definition: dvbchannel.cpp:1320
ChannelBase::Init
virtual bool Init(QString &startchannel, bool setchan)
Definition: channelbase.cpp:58
DVBChannel::Init
bool Init(QString &startchannel, bool setchan) override
Definition: dvbchannel.cpp:319
DVBChannel::m_extModulations
uint64_t m_extModulations
Definition: dvbchannel.h:139
dtvmultiplex_to_dtvproperties
static struct dtv_properties * dtvmultiplex_to_dtvproperties(DTVTunerType tuner_type, const DTVMultiplex &tuning, int intermediate_freq, bool can_fec_auto, bool do_tune=true)
Definition: dvbchannel.cpp:520
ENO
#define ENO
This can be appended to the LOG args with "+".
Definition: mythlogging.h:72
DTVCodeRate::kFEC_3_4
@ kFEC_3_4
Definition: dtvconfparserhelpers.h:292
DVBChannel::ReturnMasterLock
static void ReturnMasterLock(DVBChannel *&dvbm)
Definition: dvbchannel.cpp:1349
DTVChannel::ReturnMasterLock
static void ReturnMasterLock(DTVChannelP &chan)
Definition: dtvchannel.cpp:147
DTVTunerType::kTunerTypeDVBC
static const int kTunerTypeDVBC
Definition: dtvconfparserhelpers.h:95
dvbcam.h
DVBChannel::m_tuneLock
QMutex m_tuneLock
Definition: dvbchannel.h:146
DVBChannel::IsTuningParamsProbeSupported
bool IsTuningParamsProbeSupported(void) const
Returns true iff tuning info probing is working.
Definition: dvbchannel.cpp:846
DiSEqCDevSCR::GetIntermediateFrequency
uint32_t GetIntermediateFrequency(uint32_t frequency) const
Definition: diseqc.cpp:2254
DVBChannel::m_frontendName
QString m_frontendName
Definition: dvbchannel.h:137
DVBChannel::GetRotor
const DiSEqCDevRotor * GetRotor(void) const
Returns rotor object if it exists, nullptr otherwise.
Definition: dvbchannel.cpp:996
DTVMultiplex::m_rolloff
DTVRollOff m_rolloff
Definition: dtvmultiplex.h:107
DiSEqCDevRotor
Rotor class.
Definition: diseqc.h:297
DVBChannel::m_frequencyMinimum
uint64_t m_frequencyMinimum
Definition: dvbchannel.h:140
DVBChannel::DVBChannel
DVBChannel(QString device, TVRec *parent=nullptr)
Definition: dvbchannel.cpp:76
DTVGuardInterval::kGuardIntervalAuto
@ kGuardIntervalAuto
Definition: dtvconfparserhelpers.h:500
mythdb.h
DTVModulationSystem::kModulationSystem_DVBS2
@ kModulationSystem_DVBS2
Definition: dtvconfparserhelpers.h:660
DVBChannel::GetBitErrorRateDVBv5
double GetBitErrorRateDVBv5(bool *ok) const
Get Bit Error Rate from the DVBv5 interface.
Definition: dvbchannel.cpp:1207
DVBChannel::CheckCodeRate
bool CheckCodeRate(DTVCodeRate rate) const
Return true iff rate is supported rate on the frontend.
Definition: dvbchannel.cpp:448
DTVCodeRate::kFEC_2_3
@ kFEC_2_3
Definition: dtvconfparserhelpers.h:291
DTVChannel::s_master_map
static MasterMap s_master_map
Definition: dtvchannel.h:181
DTVModulation::kModulation32APSK
@ kModulation32APSK
Definition: dtvconfparserhelpers.h:367
DTVCodeRate::kFEC_5_6
@ kFEC_5_6
Definition: dtvconfparserhelpers.h:294
DTVTunerType::kTunerTypeDVBS1
static const int kTunerTypeDVBS1
Definition: dtvconfparserhelpers.h:93
DTVCodeRate::kFECNone
@ kFECNone
Definition: dtvconfparserhelpers.h:289
DTVModulation::kModulation16VSB
@ kModulation16VSB
Definition: dtvconfparserhelpers.h:364
DTVModulation::kModulation16APSK
@ kModulation16APSK
Definition: dtvconfparserhelpers.h:366
dtvmultiplex_to_dvbparams
static struct dvb_frontend_parameters dtvmultiplex_to_dvbparams(DTVTunerType, const DTVMultiplex &, int intermediate_freq, bool can_fec_auto)
Definition: dvbchannel.cpp:1454
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:667
DiSEqCDevTree::Execute
bool Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning)
Applies settings to the entire tree.
Definition: diseqc.cpp:513
DVBChannel::CheckOptions
void CheckOptions(DTVMultiplex &t) const override
Checks tuning for problems, and tries to fix them.
Definition: dvbchannel.cpp:343
DVBCam::Stop
bool Stop(void)
Definition: dvbcam.cpp:120
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:198
arg
arg(title).arg(filename).arg(doDelete))
DTVMultiplex::m_hierarchy
DTVHierarchy m_hierarchy
Definition: dtvmultiplex.h:103
DVBChannel::m_symbolRateMaximum
uint m_symbolRateMaximum
Definition: dvbchannel.h:143
CardUtil::HasDVBCRCBug
static bool HasDVBCRCBug(const QString &device)
Returns true if and only if the device munges PAT/PMT tables, and then doesn't fix the CRC.
Definition: cardutil.cpp:752
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
DTVHierarchy::kHierarchyAuto
@ kHierarchyAuto
Definition: dtvconfparserhelpers.h:559
ChannelBase::m_inputId
uint m_inputId
Definition: channelbase.h:137
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
DTVChannel::GetMasterLock
static DTVChannel * GetMasterLock(const QString &key)
Definition: dtvchannel.cpp:135
drain_dvb_events
static void drain_dvb_events(int fd)
Reads all the events off the queue, so we can use select in wait_for_backend(int,int).
Definition: dvbchannel.cpp:1377
DTVRollOff::kRollOff_35
@ kRollOff_35
Definition: dtvconfparserhelpers.h:736
DTVMultiplex::m_bandwidth
DTVBandwidth m_bandwidth
Definition: dtvmultiplex.h:97
DiSEqCDevSettings::Load
bool Load(uint card_input_id)
Loads configuration chain from DB for specified card input id.
Definition: diseqc.cpp:130
DVBChannel::m_key
QString m_key
Definition: dvbchannel.h:166
DVBChannel::GetSignalStrength
double GetSignalStrength(bool *ok=nullptr) const
Returns signal strength in the range [0.0..1.0] (non-calibrated).
Definition: dvbchannel.cpp:1092
DVBChannel::SetPMT
void SetPMT(const ProgramMapTable *pmt)
Tells the Conditional Access Module which streams we wish to decode.
Definition: dvbchannel.cpp:492
DVBChannel::m_isOpen
IsOpenMap m_isOpen
Definition: dvbchannel.h:128
CardUtil::ProbeTunerType
static DTVTunerType ProbeTunerType(int fd_frontend)
Definition: cardutil.cpp:817
DVBChannel::m_frequencyMaximum
uint64_t m_frequencyMaximum
Definition: dvbchannel.h:141
DTVModulation::kModulationQPSK
@ kModulationQPSK
Definition: dtvconfparserhelpers.h:356
DTVCodeRate::kFECAuto
@ kFECAuto
Definition: dtvconfparserhelpers.h:298
DVBCam::IsRunning
bool IsRunning(void) const
Definition: dvbcam.h:31
dvbchannel.h
DiSEqCDevTree::Open
void Open(int fd_frontend, bool is_SCR)
Retrieve device tree.
Definition: diseqc.cpp:798
close
#define close
Definition: compat.h:16
DVBChannel::IsMaster
bool IsMaster(void) const override
Returns true if this is the first of a number of multi-rec devs.
Definition: dvbchannel.cpp:1365
CardUtil::GetMinSignalMonitoringDelay
static uint GetMinSignalMonitoringDelay(const QString &device)
Definition: cardutil.cpp:759
DTVCodeRate
Definition: dtvconfparserhelpers.h:279
DTVTunerType
Definition: dtvconfparserhelpers.h:77
DVBChannel::m_capabilities
uint64_t m_capabilities
Definition: dvbchannel.h:138
DVBCam::SetTimeOffset
void SetTimeOffset(double offset_in_seconds)
Definition: dvbcam.cpp:320
DTVTransmitMode::kTransmissionModeAuto
@ kTransmissionModeAuto
Definition: dtvconfparserhelpers.h:435
DTVModulation::kModulationQAM256
@ kModulationQAM256
Definition: dtvconfparserhelpers.h:361
CardUtil::SetDefaultDeliverySystem
static int SetDefaultDeliverySystem(uint inputid, int fd)
Definition: cardutil.cpp:1092
DTVMultiplex::m_inversion
DTVInversion m_inversion
Definition: dtvmultiplex.h:96
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
DVBCam
Definition: dvbcam.h:24
DTVModulation::kModulationQAM16
@ kModulationQAM16
Definition: dtvconfparserhelpers.h:357
TVRec::GetInputId
uint GetInputId(void) const
Returns the inputid.
Definition: tv_rec.h:234
DVBChannel::m_prevTuning
DTVMultiplex m_prevTuning
Last tuning options Tune() succesfully sent to hardware.
Definition: dvbchannel.h:151
DTVCodeRate::kFEC_1_2
@ kFEC_1_2
Definition: dtvconfparserhelpers.h:290
DVBChannel::m_dvbCam
DVBCam * m_dvbCam
Used to decrypt encrypted streams.
Definition: dvbchannel.h:134
dvbtypes.h
DTVMultiplex::m_mplex
uint m_mplex
Definition: dtvmultiplex.h:110
ChannelBase::m_curChannelName
QString m_curChannelName
Definition: channelbase.h:135
DTVMultiplex::m_guardInterval
DTVGuardInterval m_guardInterval
Definition: dtvmultiplex.h:102
DVBChannel::Tune
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: dvbchannel.cpp:510
DVBChannel::Close
void Close(void) override
Closes the channel changing hardware to use.
Definition: dvbchannel.h:37
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
DTVChannel::SetSIStandard
void SetSIStandard(const QString &si_std)
Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
Definition: dtvchannel.cpp:50
DVBChannel::~DVBChannel
~DVBChannel() override
Definition: dvbchannel.cpp:102
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
O_NONBLOCK
#define O_NONBLOCK
Definition: mythmedia.cpp:25
DTVTunerType::IsModulationVariable
bool IsModulationVariable(void) const
Definition: dtvconfparserhelpers.h:141
DVBCam::Start
bool Start(void)
Definition: dvbcam.cpp:88
DVBChannel::GetSNR
double GetSNR(bool *ok=nullptr) const
Returns signal/noise in the range [0..1.0].
Definition: dvbchannel.cpp:1175
DVBChannel::m_symbolRateMinimum
uint m_symbolRateMinimum
Definition: dvbchannel.h:142
DVBChannel::m_sigMonDelay
uint m_sigMonDelay
Minimum delay between FE_LOCK checks.
Definition: dvbchannel.h:158
DVBChannel::m_fdFrontend
int m_fdFrontend
File descriptor for tuning hardware.
Definition: dvbchannel.h:164
DiSEqCDevSCR
Unicable / SCR Class.
Definition: diseqc.h:377
DTVTunerType::toString
QString toString() const
Definition: dtvconfparserhelpers.h:154
DTVModulation::kModulationQAM128
@ kModulationQAM128
Definition: dtvconfparserhelpers.h:360
DTVMultiplex::m_hpCodeRate
DTVCodeRate m_hpCodeRate
High Priority FEC rate.
Definition: dtvmultiplex.h:98
DVBChannel::Tune
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
DTVInversion::kInversionAuto
@ kInversionAuto
Definition: dtvconfparserhelpers.h:173
LOC
#define LOC
Definition: dvbchannel.cpp:69
DTVModulation::kModulationQAM32
@ kModulationQAM32
Definition: dtvconfparserhelpers.h:358
DVBChannel::m_diseqcSettings
DiSEqCDevSettings m_diseqcSettings
Definition: dvbchannel.h:131
DTVInversion::kInversionOff
@ kInversionOff
Definition: dtvconfparserhelpers.h:171
DiSEqCDevLNB
LNB Class.
Definition: diseqc.h:442
DTVMultiplex::m_modSys
DTVModulationSystem m_modSys
Modulation system.
Definition: dtvmultiplex.h:106
DTVModulation::kModulationQAMAuto
@ kModulationQAMAuto
Definition: dtvconfparserhelpers.h:362
DTVMultiplex::m_fec
DTVCodeRate m_fec
Inner Forward Error Correction rate.
Definition: dtvmultiplex.h:105
DTVMultiplex::toString
QString toString() const
Definition: dtvmultiplex.cpp:34
wait_for_backend
static bool wait_for_backend(int fd, int timeout_ms)
Waits for backend to get tune message.
Definition: dvbchannel.cpp:1411
uint
unsigned int uint
Definition: compat.h:140
DVBChannel::m_tuningDelay
uint m_tuningDelay
Extra delay to add for broken drivers.
Definition: dvbchannel.h:156
DVBChannel::m_lastLnbDevId
uint m_lastLnbDevId
Definition: dvbchannel.h:153
DiSEqCDev::FindTree
static DiSEqCDevTree * FindTree(uint cardid)
Retrieve device tree.
Definition: diseqc.cpp:239
DVBChannel::m_desiredTuning
DTVMultiplex m_desiredTuning
Last tuning options Tune() attempted to send to hardware.
Definition: dvbchannel.h:149
DVBChannel::GetUncorrectedBlockCountDVBv5
double GetUncorrectedBlockCountDVBv5(bool *ok) const
Get Uncorrected Block Count from the DVBv5 interface.
Definition: dvbchannel.cpp:1285
DTVTunerType::IsFECVariable
bool IsFECVariable(void) const
Definition: dtvconfparserhelpers.h:134
DVBChannel::Retune
bool Retune(void) override
Definition: dvbchannel.cpp:838
DTVBandwidth::kBandwidthAuto
@ kBandwidthAuto
Definition: dtvconfparserhelpers.h:229
channelutil.h
DTVTunerType::kTunerTypeDVBS2
static const int kTunerTypeDVBS2
Definition: dtvconfparserhelpers.h:94
DTVMultiplex::m_symbolRate
uint64_t m_symbolRate
Definition: dtvmultiplex.h:95
DiSEqCDevTree::FindLNB
DiSEqCDevLNB * FindLNB(const DiSEqCDevSettings &settings)
Returns the LNB device object selected by the configuration chain.
Definition: diseqc.cpp:577
DTVModulationSystem::toString
QString toString() const
Definition: dtvconfparserhelpers.h:719
CardUtil::GetDeviceName
static QString GetDeviceName(dvb_dev_type_t type, const QString &device)
Definition: cardutil.cpp:2723
DVBChannel::GetBitErrorRate
double GetBitErrorRate(bool *ok=nullptr) const
Returns # of corrected bits since last call. First call undefined.
Definition: dvbchannel.cpp:1255
DiSEqCDevTree::Close
void Close(void)
Definition: diseqc.h:103
DVBChannel
Provides interface to the tuning hardware when using DVB drivers.
Definition: dvbchannel.h:30
DVBChannel::Open
bool Open(void) override
Opens the channel changing hardware for use.
Definition: dvbchannel.h:35
DVBChannel::GetSNRDVBv5
double GetSNRDVBv5(bool *ok) const
Get SNR from the DVBv5 interface [0-1.0] It is transformed to a linear relative scale if provided in ...
Definition: dvbchannel.cpp:1124
DTVChannel::m_tunerType
DTVTunerType m_tunerType
Definition: dtvchannel.h:163
VERBOSE_LEVEL_CHECK
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_)
Definition: mythlogging.h:14
DTVChannel::s_master_map_lock
static QReadWriteLock s_master_map_lock
Definition: dtvchannel.h:180
DiSEqCDevTree::FindRotor
DiSEqCDevRotor * FindRotor(const DiSEqCDevSettings &settings, uint index=0)
Returns the nth rotor device object in the tree.
Definition: diseqc.cpp:554
cardutil.h
concurrent_tunings_delay
int64_t concurrent_tunings_delay
Definition: dvbchannel.cpp:66
DVBChannel::m_firstTune
bool m_firstTune
Used to force hardware reset.
Definition: dvbchannel.h:160
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
DVBChannel::SetTimeOffset
void SetTimeOffset(double offset)
Tells the Conditional Access Module the offset from the computers utc time to dvb time.
Definition: dvbchannel.cpp:504
DVBChannel::CheckFrequency
void CheckFrequency(uint64_t frequency) const
Checks tuning frequency.
Definition: dvbchannel.cpp:330
DVBChannel::m_diseqcTree
DiSEqCDevTree * m_diseqcTree
Definition: dvbchannel.h:132
DTVTunerType::IsDiSEqCSupported
bool IsDiSEqCSupported(void) const
Definition: dtvconfparserhelpers.h:148
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:143
DVBChannel::s_lastTuning
static QDateTime s_lastTuning
Definition: dvbchannel.h:170
DTVMultiplex::m_sistandard
QString m_sistandard
Definition: dtvmultiplex.h:111
DVBCam::SetPMT
void SetPMT(const ChannelBase *chan, const ProgramMapTable *pmt)
Definition: dvbcam.cpp:287
DiSEqCDevTree::FindSCR
DiSEqCDevSCR * FindSCR(const DiSEqCDevSettings &settings)
Returns the SCR device object selected by the configuration chain.
Definition: diseqc.cpp:600
CardUtil::GetSourceID
static uint GetSourceID(uint inputid)
Definition: cardutil.cpp:1786
DVBChannel::ProbeTuningParams
bool ProbeTuningParams(DTVMultiplex &tuning) const
Fetches DTVMultiplex params from driver.
Definition: dvbchannel.cpp:892
DVBChannel::HasLock
bool HasLock(bool *ok=nullptr) const
Returns true iff we have a signal carrier lock.
Definition: dvbchannel.cpp:1005
tv_rec.h
DVBChannel::m_hasCrcBug
bool m_hasCrcBug
true iff our driver munges PMT
Definition: dvbchannel.h:168
DVBChannel::m_device
QString m_device
Definition: dvbchannel.h:165
DVBChannel::GetMasterLock
DVBChannel * GetMasterLock(void) const
Definition: dvbchannel.cpp:1356
DTVModulation::kModulation8VSB
@ kModulation8VSB
Definition: dtvconfparserhelpers.h:363
DTVMultiplex::m_modulation
DTVModulation m_modulation
Definition: dtvmultiplex.h:100
DTVTunerType::kTunerTypeATSC
static const int kTunerTypeATSC
Definition: dtvconfparserhelpers.h:98
DVBChannel::IsOpen
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: dvbchannel.cpp:311
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:1
DVBChannel::GetChanID
int GetChanID(void) const override
Returns Channel ID.
Definition: dvbchannel.cpp:950
DVB_DEV_FRONTEND
@ DVB_DEV_FRONTEND
Definition: cardutil.h:29
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:35
DTVCodeRate::kFEC_7_8
@ kFEC_7_8
Definition: dtvconfparserhelpers.h:296
DiSEqCDevDevice::GetDeviceID
uint GetDeviceID(void) const
Definition: diseqc.h:165
DTVTunerType::kTunerTypeDVBT
static const int kTunerTypeDVBT
Definition: dtvconfparserhelpers.h:96
dvbparams_to_dtvmultiplex
static DTVMultiplex dvbparams_to_dtvmultiplex(DTVTunerType, const dvb_frontend_parameters &)
Definition: dvbchannel.cpp:1520
DTVMultiplex::IsEqual
bool IsEqual(DTVTunerType type, const DTVMultiplex &other, uint freq_range=0, bool fuzzy=false) const
Definition: dtvmultiplex.cpp:50
ENOTSUPP
#define ENOTSUPP
Definition: dvbchannel.cpp:55
DTVTunerType::kTunerTypeDVBT2
static const int kTunerTypeDVBT2
Definition: dtvconfparserhelpers.h:97
DVBChannel::GetSignalStrengthDVBv5
double GetSignalStrengthDVBv5(bool *ok) const
Get Signal strength from the DVBv5 interface [0-1.0] It is transformed to a linear relative scale if ...
Definition: dvbchannel.cpp:1037
ChannelBase::InitializeInput
virtual bool InitializeInput(void)
Fills in input map from DB.
Definition: channelbase.cpp:547
DVBChannel::m_tuneDelayLock
QMutex m_tuneDelayLock
Definition: dvbchannel.h:171
DTVCodeRate::kFEC_8_9
@ kFEC_8_9
Definition: dtvconfparserhelpers.h:297
DTVModulation::kModulationQAM64
@ kModulationQAM64
Definition: dtvconfparserhelpers.h:359
query
MSqlQuery query(MSqlQuery::InitCon())
DTVCodeRate::kFEC_6_7
@ kFEC_6_7
Definition: dtvconfparserhelpers.h:295
DTVModulationSystem::kModulationSystem_DVBS
@ kModulationSystem_DVBS
Definition: dtvconfparserhelpers.h:659
DTVMultiplex::m_transMode
DTVTransmitMode m_transMode
Definition: dtvmultiplex.h:101
DVBChannel::m_hwLock
QMutex m_hwLock
Definition: dvbchannel.h:147
DTVModulation::kModulation8PSK
@ kModulation8PSK
Definition: dtvconfparserhelpers.h:365
ChannelBase::m_pParent
TVRec * m_pParent
Definition: channelbase.h:134
DTVModulation
Definition: dtvconfparserhelpers.h:346
DiSEqCDevLNB::GetIntermediateFrequency
uint32_t GetIntermediateFrequency(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) const
Calculate proper intermediate frequency for the given settings and tuning parameters.
Definition: diseqc.cpp:2561
DTVCodeRate::kFEC_4_5
@ kFEC_4_5
Definition: dtvconfparserhelpers.h:293
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808
DTVMultiplex::m_lpCodeRate
DTVCodeRate m_lpCodeRate
Low Priority FEC rate.
Definition: dtvmultiplex.h:99