vdr  2.0.2
dvbdevice.h
Go to the documentation of this file.
1 /*
2  * dvbdevice.h: The DVB device tuner interface
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: dvbdevice.h 2.29.1.1 2013/04/09 13:43:33 kls Exp $
8  */
9 
10 #ifndef __DVBDEVICE_H
11 #define __DVBDEVICE_H
12 
13 #include <linux/dvb/frontend.h>
14 #include <linux/dvb/version.h>
15 #include "device.h"
16 
17 #define DVBAPIVERSION (DVB_API_VERSION << 8 | DVB_API_VERSION_MINOR)
18 
19 #if DVBAPIVERSION < 0x0500
20 #error VDR requires Linux DVB driver API version 5.0 or higher!
21 #endif
22 
23 // --- Definitions for older DVB API versions --------------------------------
24 
25 #if DVBAPIVERSION < 0x0501
26 enum {
27  FE_CAN_2G_MODULATION = 0x10000000,
28  };
29 enum {
30  TRANSMISSION_MODE_4K = TRANSMISSION_MODE_AUTO + 1,
31  };
32 #endif
33 
34 #if DVBAPIVERSION < 0x0502
35 enum {
36  FE_CAN_TURBO_FEC = 0x8000000,
37  };
38 #endif
39 
40 #if DVBAPIVERSION < 0x0503
41 enum {
45  };
46 enum {
47  GUARD_INTERVAL_1_128 = GUARD_INTERVAL_AUTO + 1,
50  };
51 enum {
52  SYS_DVBT2 = SYS_DAB + 1,
53  };
54 #endif
55 
56 #if DVBAPIVERSION < 0x0505
57 #define DTV_ENUM_DELSYS 44
58 #endif
59 
60 #if DVBAPIVERSION < 0x0508
61 enum {
62  FE_CAN_MULTISTREAM = 0x4000000,
63  };
64 #define DTV_STREAM_ID 42
65 #define DTV_DVBT2_PLP_ID_LEGACY 43
66 #endif
67 
68 // --- End of definitions for older DVB API versions -------------------------
69 
70 #define MAXDVBDEVICES 8
71 #define MAXDELIVERYSYSTEMS 8
72 
73 #define DEV_VIDEO "/dev/video"
74 #define DEV_DVB_BASE "/dev/dvb"
75 #define DEV_DVB_ADAPTER "adapter"
76 #define DEV_DVB_OSD "osd"
77 #define DEV_DVB_FRONTEND "frontend"
78 #define DEV_DVB_DVR "dvr"
79 #define DEV_DVB_DEMUX "demux"
80 #define DEV_DVB_VIDEO "video"
81 #define DEV_DVB_AUDIO "audio"
82 #define DEV_DVB_CA "ca"
83 
85  int userValue;
87  const char *userString;
88  };
89 
90 const char *MapToUserString(int Value, const tDvbParameterMap *Map);
91 int MapToUser(int Value, const tDvbParameterMap *Map, const char **String = NULL);
92 int MapToDriver(int Value, const tDvbParameterMap *Map);
93 int UserIndex(int Value, const tDvbParameterMap *Map);
94 int DriverIndex(int Value, const tDvbParameterMap *Map);
95 
96 extern const tDvbParameterMap InversionValues[];
97 extern const tDvbParameterMap BandwidthValues[];
98 extern const tDvbParameterMap CoderateValues[];
99 extern const tDvbParameterMap ModulationValues[];
100 extern const tDvbParameterMap SystemValuesSat[];
101 extern const tDvbParameterMap SystemValuesTerr[];
102 extern const tDvbParameterMap TransmissionValues[];
103 extern const tDvbParameterMap GuardValues[];
104 extern const tDvbParameterMap HierarchyValues[];
105 extern const tDvbParameterMap RollOffValues[];
106 
108 friend class cDvbSourceParam;
109 private:
116  int system;
118  int guard;
120  int rollOff;
121  int streamId;
122  int PrintParameter(char *p, char Name, int Value) const;
123  const char *ParseParameter(const char *s, int &Value, const tDvbParameterMap *Map = NULL);
124 public:
125  cDvbTransponderParameters(const char *Parameters = NULL);
126  char Polarization(void) const { return polarization; }
127  int Inversion(void) const { return inversion; }
128  int Bandwidth(void) const { return bandwidth; }
129  int CoderateH(void) const { return coderateH; }
130  int CoderateL(void) const { return coderateL; }
131  int Modulation(void) const { return modulation; }
132  int System(void) const { return system; }
133  int Transmission(void) const { return transmission; }
134  int Guard(void) const { return guard; }
135  int Hierarchy(void) const { return hierarchy; }
136  int RollOff(void) const { return rollOff; }
137  int StreamId(void) const { return streamId; }
144  void SetSystem(int System) { system = System; }
146  void SetGuard(int Guard) { guard = Guard; }
150  cString ToString(char Type) const;
151  bool Parse(const char *s);
152  };
153 
154 class cDvbTuner;
155 
157 
158 class cDvbDevice : public cDevice {
159 protected:
160  static cString DvbName(const char *Name, int Adapter, int Frontend);
161  static int DvbOpen(const char *Name, int Adapter, int Frontend, int Mode, bool ReportError = false);
162 private:
163  static bool Exists(int Adapter, int Frontend);
165  static bool Probe(int Adapter, int Frontend);
167 public:
168  static bool Initialize(void);
172 protected:
174 private:
175  dvb_frontend_info frontendInfo;
179  int fd_dvr, fd_ca;
183  bool QueryDeliverySystems(int fd_frontend);
184 public:
185  cDvbDevice(int Adapter, int Frontend);
186  virtual ~cDvbDevice();
187  int Adapter(void) const { return adapter; }
188  int Frontend(void) const { return frontend; }
189  virtual bool Ready(void);
190  virtual cString DeviceType(void) const;
191  virtual cString DeviceName(void) const;
192  static bool BondDevices(const char *Bondings);
198  static void UnBondDevices(void);
200  bool Bond(cDvbDevice *Device);
208  void UnBond(void);
212  bool BondingOk(const cChannel *Channel, bool ConsiderOccupied = false) const;
219 
220 // Common Interface facilities:
221 
222 private:
224 
225 // Channel facilities
226 
227 private:
229 public:
230  virtual bool ProvidesDeliverySystem(int DeliverySystem) const;
231  virtual bool ProvidesSource(int Source) const;
232  virtual bool ProvidesTransponder(const cChannel *Channel) const;
233  virtual bool ProvidesChannel(const cChannel *Channel, int Priority = IDLEPRIORITY, bool *NeedsDetachReceivers = NULL) const;
234  virtual bool ProvidesEIT(void) const;
235  virtual int NumProvidedSystems(void) const;
236  virtual int SignalStrength(void) const;
237  virtual int SignalQuality(void) const;
238  virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
239  virtual bool IsTunedToTransponder(const cChannel *Channel) const;
240  virtual bool MaySwitchTransponder(const cChannel *Channel) const;
241 protected:
242  virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
243 public:
244  virtual bool HasLock(int TimeoutMs = 0) const;
245 
246 // PID handle facilities
247 
248 protected:
249  virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
250 
251 // Section filter facilities
252 
253 protected:
254  virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
255  virtual void CloseFilter(int Handle);
256 
257 // Common Interface facilities:
258 
259 public:
260  virtual bool HasCi(void);
261 
262 // Audio facilities
263 
264 protected:
266 public:
267  static void SetTransferModeForDolbyDigital(int Mode); // needs to be here for backwards compatibility
273 
274 // Receiver facilities
275 
276 private:
278 protected:
279  virtual bool OpenDvr(void);
280  virtual void CloseDvr(void);
281  virtual bool GetTSPacket(uchar *&Data);
282  virtual void DetachAllReceivers(void);
283  };
284 
285 // A plugin that implements a DVB device derived from cDvbDevice needs to create
286 // a cDvbDeviceProbe derived object on the heap in order to have its Probe()
287 // function called, where it can actually create the appropriate device.
288 // The cDvbDeviceProbe object must be created in the plugin's constructor,
289 // and deleted in its destructor.
290 
291 class cDvbDeviceProbe : public cListObject {
292 public:
293  cDvbDeviceProbe(void);
294  virtual ~cDvbDeviceProbe();
295  static uint32_t GetSubsystemId(int Adapter, int Frontend);
296  virtual bool Probe(int Adapter, int Frontend) = 0;
300  };
301 
303 
304 #endif //__DVBDEVICE_H
305