vdr 2.6.1
include/vdr/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 4.7 2020/06/27 10:24:46 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
26enum {
28 };
29enum {
30 TRANSMISSION_MODE_4K = TRANSMISSION_MODE_AUTO + 1,
31 };
32#endif
33
34#if DVBAPIVERSION < 0x0502
35enum {
36 FE_CAN_TURBO_FEC = 0x8000000,
37 };
38#endif
39
40#if DVBAPIVERSION < 0x0503
41enum {
45 };
46enum {
47 GUARD_INTERVAL_1_128 = GUARD_INTERVAL_AUTO + 1,
50 };
51enum {
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
61enum {
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 DEV_VIDEO "/dev/video"
71#define DEV_DVB_BASE "/dev/dvb"
72#define DEV_DVB_ADAPTER "adapter"
73#define DEV_DVB_OSD "osd"
74#define DEV_DVB_FRONTEND "frontend"
75#define DEV_DVB_DVR "dvr"
76#define DEV_DVB_DEMUX "demux"
77#define DEV_DVB_VIDEO "video"
78#define DEV_DVB_AUDIO "audio"
79#define DEV_DVB_CA "ca"
80
81struct tDvbParameterMap {
82 int userValue;
83 int driverValue;
84 const char *userString;
85 };
86
87const char *MapToUserString(int Value, const tDvbParameterMap *Map);
88int MapToUser(int Value, const tDvbParameterMap *Map, const char **String = NULL);
89int MapToDriver(int Value, const tDvbParameterMap *Map);
90int UserIndex(int Value, const tDvbParameterMap *Map);
91int DriverIndex(int Value, const tDvbParameterMap *Map);
92
93extern const tDvbParameterMap PilotValues[];
96extern const tDvbParameterMap CoderateValues[];
101extern const tDvbParameterMap GuardValues[];
102extern const tDvbParameterMap HierarchyValues[];
103extern const tDvbParameterMap RollOffValues[];
104
106friend class cDvbSourceParam;
107private:
108 char polarization;
109 int inversion;
110 int bandwidth;
111 int coderateH;
112 int coderateL;
113 int modulation;
114 int system;
115 int transmission;
116 int guard;
117 int hierarchy;
118 int rollOff;
119 int streamId;
120 int t2systemId;
121 int sisoMiso;
122 int pilot;
123 int PrintParameter(char *p, char Name, int Value) const;
124 const char *ParseParameter(const char *s, int &Value, const tDvbParameterMap *Map = NULL);
125public:
126 cDvbTransponderParameters(const char *Parameters = NULL);
127 char Polarization(void) const { return polarization; }
128 int Inversion(void) const { return inversion; }
129 int Bandwidth(void) const { return bandwidth; }
130 int CoderateH(void) const { return coderateH; }
131 int CoderateL(void) const { return coderateL; }
132 int Modulation(void) const { return modulation; }
133 int System(void) const { return system; }
134 int Transmission(void) const { return transmission; }
135 int Guard(void) const { return guard; }
136 int Hierarchy(void) const { return hierarchy; }
137 int RollOff(void) const { return rollOff; }
138 int StreamId(void) const { return streamId; }
139 int T2SystemId(void) const { return t2systemId; }
140 int SisoMiso(void) const { return sisoMiso; }
141 int Pilot(void) const { return pilot; }
148 void SetSystem(int System) { system = System; }
150 void SetGuard(int Guard) { guard = Guard; }
156 void SetPilot(int Pilot) { pilot = Pilot; }
157 cString ToString(char Type) const;
158 bool Parse(const char *s);
159 };
160
161class cDvbTuner;
162
163cString DvbName(const char *Name, int Adapter, int Frontend);
164int DvbOpen(const char *Name, int Adapter, int Frontend, int Mode, bool ReportError = false);
165
167
168class cDvbDevice : public cDevice {
169private:
170 static bool Exists(int Adapter, int Frontend);
172 static bool Probe(int Adapter, int Frontend);
174public:
175 static bool useDvbDevices;
176 static bool Initialize(void);
180protected:
181 int adapter, frontend;
182 virtual bool IsBonded(void) const { return bondedDevice; }
183private:
184 int fd_dvr, fd_ca;
185 bool checkTsBuffer;
186 static cMutex bondMutex;
188 mutable bool needsDetachBondedReceivers;
189public:
191 virtual ~cDvbDevice();
192 int Adapter(void) const { return adapter; }
193 int Frontend(void) const;
194 virtual cString DeviceType(void) const;
195 virtual cString DeviceName(void) const;
196 static bool BondDevices(const char *Bondings);
202 static void UnBondDevices(void);
204 bool Bond(cDvbDevice *Device);
212 void UnBond(void);
216 bool BondingOk(const cChannel *Channel, bool ConsiderOccupied = false) const;
223
224// Common Interface facilities:
225
226private:
228
229// Channel facilities
230
231private:
233public:
234 virtual bool ProvidesDeliverySystem(int DeliverySystem) const;
235 virtual bool ProvidesSource(int Source) const;
236 virtual bool ProvidesTransponder(const cChannel *Channel) const;
237 virtual bool ProvidesChannel(const cChannel *Channel, int Priority = IDLEPRIORITY, bool *NeedsDetachReceivers = NULL) const;
238 virtual bool ProvidesEIT(void) const;
239 virtual int NumProvidedSystems(void) const;
240 virtual const cPositioner *Positioner(void) const;
241 virtual bool SignalStats(int &Valid, double *Strength = NULL, double *Cnr = NULL, double *BerPre = NULL, double *BerPost = NULL, double *Per = NULL, int *Status = NULL) const;
242 virtual int SignalStrength(void) const;
243 virtual int SignalQuality(void) const;
244 virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
245 virtual bool IsTunedToTransponder(const cChannel *Channel) const;
246 virtual bool MaySwitchTransponder(const cChannel *Channel) const;
247protected:
248 virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
249public:
250 virtual bool HasLock(int TimeoutMs = 0) const;
251
252// PID handle facilities
253
254protected:
255 virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
256
257// Section filter facilities
258
259protected:
260 virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
261 virtual void CloseFilter(int Handle);
262
263// Common Interface facilities:
264
265public:
266 virtual bool HasCi(void);
267
268// Audio facilities
269
270protected:
272public:
273 static void SetTransferModeForDolbyDigital(int Mode); // needs to be here for backwards compatibility
279
280// Receiver facilities
281
282private:
284protected:
285 virtual bool OpenDvr(void);
286 virtual void CloseDvr(void);
287 virtual bool GetTSPacket(uchar *&Data);
288 virtual void DetachAllReceivers(void);
289 };
290
291// A plugin that implements a DVB device derived from cDvbDevice needs to create
292// a cDvbDeviceProbe derived object on the heap in order to have its Probe()
293// function called, where it can actually create the appropriate device.
294// The cDvbDeviceProbe object must be created in the plugin's constructor,
295// and deleted in its destructor.
296
297class cDvbDeviceProbe : public cListObject {
298public:
301 static uint32_t GetSubsystemId(int Adapter, int Frontend);
302 virtual bool Probe(int Adapter, int Frontend) = 0;
306 };
307
309
310#endif //__DVBDEVICE_H
Definition: ci.h:172
int Priority(void) const
Returns the priority of the current receiving session (-MAXPRIORITY..MAXPRIORITY),...
Definition: device.c:1660
virtual ~cDvbDeviceProbe()
static uint32_t GetSubsystemId(int Adapter, int Frontend)
virtual bool Probe(int Adapter, int Frontend)=0
Probes for a DVB device at the given Adapter and creates the appropriate object derived from cDvbDevi...
The cDvbDevice implements a DVB device which can be accessed through the Linux DVB driver API.
Definition: dvbdevice.h:168
virtual ~cDvbDevice()
virtual void DetachAllReceivers(void)
Detaches all receivers from this device.
cDvbDevice(int Adapter, int Frontend)
cCiAdapter * ciAdapter
Definition: dvbdevice.h:227
virtual bool ProvidesEIT(void) const
Returns true if this device provides EIT data and thus wants to be tuned to the channels it can recei...
static bool Exists(int Adapter, int Frontend)
Checks whether the given adapter/frontend exists.
virtual cString DeviceType(void) const
Returns a string identifying the type of this device (like "DVB-S").
static int setTransferModeForDolbyDigital
Definition: dvbdevice.h:271
virtual bool ProvidesTransponder(const cChannel *Channel) const
Returns true if this device can provide the transponder of the given Channel (which implies that it c...
virtual void CloseFilter(int Handle)
Closes a file handle that has previously been opened by OpenFilter().
virtual bool SetPid(cPidHandle *Handle, int Type, bool On)
Does the actual PID setting on this device.
virtual const cPositioner * Positioner(void) const
Returns a pointer to the positioner (if any) this device has used to move the satellite dish to the r...
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask)
Opens a file handle for the given filter data.
virtual bool ProvidesSource(int Source) const
Returns true if this device can provide the given source.
virtual bool SignalStats(int &Valid, double *Strength=NULL, double *Cnr=NULL, double *BerPre=NULL, double *BerPost=NULL, double *Per=NULL, int *Status=NULL) const
Returns statistics about the currently received signal (if available).
bool checkTsBuffer
Definition: dvbdevice.h:185
virtual bool IsTunedToTransponder(const cChannel *Channel) const
Returns true if this device is currently tuned to the given Channel's transponder.
cDvbDevice * bondedDevice
Definition: dvbdevice.h:187
static bool BondDevices(const char *Bondings)
Bonds the devices as defined in the given Bondings string.
virtual bool ProvidesDeliverySystem(int DeliverySystem) const
void UnBond(void)
Removes this device from any bonding it might have with other devices.
virtual const cChannel * GetCurrentlyTunedTransponder(void) const
Returns a pointer to the currently tuned transponder.
int adapter
Definition: dvbdevice.h:181
static cMutex bondMutex
Definition: dvbdevice.h:186
cDvbTuner * dvbTuner
Definition: dvbdevice.h:232
virtual bool HasLock(int TimeoutMs=0) const
Returns true if the device has a lock on the requested transponder.
bool BondingOk(const cChannel *Channel, bool ConsiderOccupied=false) const
Returns true if this device is either not bonded to any other device, or the given Channel is on the ...
virtual bool HasCi(void)
Returns true if this device has a Common Interface.
static void SetTransferModeForDolbyDigital(int Mode)
virtual bool MaySwitchTransponder(const cChannel *Channel) const
Returns true if it is ok to switch to the Channel's transponder on this device, without disturbing an...
bool needsDetachBondedReceivers
Definition: dvbdevice.h:188
static bool Probe(int Adapter, int Frontend)
Probes for existing DVB devices.
virtual bool IsBonded(void) const
Returns true if this device is bonded to an other device.
int Frontend(void) const
Definition: dvbdevice.c:1887
virtual bool ProvidesChannel(const cChannel *Channel, int Priority=IDLEPRIORITY, bool *NeedsDetachReceivers=NULL) const
Returns true if this device can provide the given channel.
virtual int SignalQuality(void) const
Returns the "quality" of the currently received signal.
static void UnBondDevices(void)
Unbonds all devices.
virtual bool OpenDvr(void)
Opens the DVR of this device and prepares it to deliver a Transport Stream for use in a cReceiver.
bool Bond(cDvbDevice *Device)
Bonds this device with the given Device, making both of them use the same satellite cable and LNB.
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView)
Sets the device to the given channel (actual physical setup).
virtual cString DeviceName(void) const
Returns a string identifying the name of this device.
virtual int NumProvidedSystems(void) const
Returns the number of individual "delivery systems" this device provides.
virtual void CloseDvr(void)
Shuts down the DVR.
int frontend
Definition: dvbdevice.h:181
virtual int SignalStrength(void) const
Returns the "strength" of the currently received signal.
int fd_dvr
Definition: dvbdevice.h:184
virtual bool GetTSPacket(uchar *&Data)
Gets exactly one TS packet from the DVR of this device and returns a pointer to it in Data.
cTSBuffer * tsBuffer
< Controls how the DVB device handles Transfer Mode when replaying Dolby Digital audio.
Definition: dvbdevice.h:283
static bool useDvbDevices
Definition: dvbdevice.h:175
int Adapter(void) const
Definition: dvbdevice.h:192
static bool Initialize(void)
Initializes the DVB devices.
cString ToString(char Type) const
const char * ParseParameter(const char *s, int &Value, const tDvbParameterMap *Map=NULL)
void SetModulation(int Modulation)
void SetInversion(int Inversion)
void SetCoderateL(int CoderateL)
void SetCoderateH(int CoderateH)
void SetT2SystemId(int T2SystemId)
bool Parse(const char *s)
void SetBandwidth(int Bandwidth)
int PrintParameter(char *p, char Name, int Value) const
void SetPolarization(char Polarization)
void SetTransmission(int Transmission)
cDvbTransponderParameters(const char *Parameters=NULL)
void SetHierarchy(int Hierarchy)
int Frontend(void) const
Definition: dvbdevice.c:577
A steerable satellite dish generally points to the south on the northern hemisphere,...
Derived cDevice classes that can receive channels will have to provide Transport Stream (TS) packets ...
Definition: device.h:876
#define IDLEPRIORITY
Definition: config.h:47
const tDvbParameterMap CoderateValues[]
Definition: dvbdevice.c:65
const tDvbParameterMap PilotValues[]
Definition: dvbdevice.c:41
const tDvbParameterMap GuardValues[]
Definition: dvbdevice.c:124
const tDvbParameterMap SystemValuesSat[]
Definition: dvbdevice.c:101
int DvbOpen(const char *Name, int Adapter, int Frontend, int Mode, bool ReportError=false)
Definition: dvbdevice.c:1878
const tDvbParameterMap HierarchyValues[]
Definition: dvbdevice.c:136
@ TRANSMISSION_MODE_4K
int DriverIndex(int Value, const tDvbParameterMap *Map)
Definition: dvbdevice.c:164
cString DvbName(const char *Name, int Adapter, int Frontend)
Definition: dvbdevice.c:1873
@ FE_CAN_2G_MODULATION
const tDvbParameterMap BandwidthValues[]
Definition: dvbdevice.c:55
int MapToUser(int Value, const tDvbParameterMap *Map, const char **String=NULL)
Definition: dvbdevice.c:175
@ GUARD_INTERVAL_19_128
@ GUARD_INTERVAL_19_256
@ GUARD_INTERVAL_1_128
@ FE_CAN_MULTISTREAM
cList< cDvbDeviceProbe > DvbDeviceProbes
Definition: dvbdevice.c:2372
const tDvbParameterMap TransmissionValues[]
Definition: dvbdevice.c:113
const tDvbParameterMap InversionValues[]
Definition: dvbdevice.c:48
const tDvbParameterMap RollOffValues[]
Definition: dvbdevice.c:145
const tDvbParameterMap ModulationValues[]
Definition: dvbdevice.c:81
const tDvbParameterMap SystemValuesTerr[]
Definition: dvbdevice.c:107
@ TRANSMISSION_MODE_16K
@ TRANSMISSION_MODE_1K
@ TRANSMISSION_MODE_32K
int UserIndex(int Value, const tDvbParameterMap *Map)
Definition: dvbdevice.c:153
const char * MapToUserString(int Value, const tDvbParameterMap *Map)
Definition: dvbdevice.c:186
int MapToDriver(int Value, const tDvbParameterMap *Map)
Definition: dvbdevice.c:194
@ FE_CAN_TURBO_FEC
unsigned char uchar
unsigned char u_char
const char * userString
Definition: dvbdevice.h:84