2002-08-04 14:57:29 +02:00
|
|
|
/*
|
2009-12-31 15:38:18 +01:00
|
|
|
* dvbdevice.h: The DVB device tuner interface
|
2002-08-04 14:57:29 +02:00
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2012-03-13 10:20:42 +01:00
|
|
|
* $Id: dvbdevice.h 2.25 2012/03/13 10:11:15 kls Exp $
|
2002-08-04 14:57:29 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DVBDEVICE_H
|
|
|
|
#define __DVBDEVICE_H
|
|
|
|
|
2002-08-10 14:58:25 +02:00
|
|
|
#include <linux/dvb/frontend.h>
|
2002-11-03 12:31:51 +01:00
|
|
|
#include <linux/dvb/version.h>
|
2002-08-04 14:57:29 +02:00
|
|
|
#include "device.h"
|
|
|
|
|
2012-01-16 12:53:38 +01:00
|
|
|
#if (DVB_API_VERSION << 8 | DVB_API_VERSION_MINOR) < 0x0503
|
2012-01-11 13:22:51 +01:00
|
|
|
#error VDR requires Linux DVB driver API version 5.3 or higher!
|
2002-11-03 12:31:51 +01:00
|
|
|
#endif
|
|
|
|
|
2007-02-25 12:25:57 +01:00
|
|
|
#define MAXDVBDEVICES 8
|
2012-01-08 09:27:59 +01:00
|
|
|
#define MAXDELIVERYSYSTEMS 8
|
2002-09-04 17:26:02 +02:00
|
|
|
|
2009-12-31 15:38:18 +01:00
|
|
|
#define DEV_VIDEO "/dev/video"
|
2012-02-17 12:38:57 +01:00
|
|
|
#define DEV_DVB_BASE "/dev/dvb"
|
|
|
|
#define DEV_DVB_ADAPTER "adapter"
|
2009-12-31 15:38:18 +01:00
|
|
|
#define DEV_DVB_OSD "osd"
|
|
|
|
#define DEV_DVB_FRONTEND "frontend"
|
|
|
|
#define DEV_DVB_DVR "dvr"
|
|
|
|
#define DEV_DVB_DEMUX "demux"
|
|
|
|
#define DEV_DVB_VIDEO "video"
|
|
|
|
#define DEV_DVB_AUDIO "audio"
|
|
|
|
#define DEV_DVB_CA "ca"
|
|
|
|
|
2010-02-28 12:19:50 +01:00
|
|
|
struct tDvbParameterMap {
|
|
|
|
int userValue;
|
|
|
|
int driverValue;
|
|
|
|
const char *userString;
|
|
|
|
};
|
|
|
|
|
2010-04-11 13:02:42 +02:00
|
|
|
const char *MapToUserString(int Value, const tDvbParameterMap *Map);
|
2010-02-28 12:19:50 +01:00
|
|
|
int MapToUser(int Value, const tDvbParameterMap *Map, const char **String = NULL);
|
|
|
|
int MapToDriver(int Value, const tDvbParameterMap *Map);
|
|
|
|
int UserIndex(int Value, const tDvbParameterMap *Map);
|
|
|
|
int DriverIndex(int Value, const tDvbParameterMap *Map);
|
|
|
|
|
|
|
|
extern const tDvbParameterMap InversionValues[];
|
|
|
|
extern const tDvbParameterMap BandwidthValues[];
|
|
|
|
extern const tDvbParameterMap CoderateValues[];
|
|
|
|
extern const tDvbParameterMap ModulationValues[];
|
2012-01-08 09:27:59 +01:00
|
|
|
extern const tDvbParameterMap SystemValuesSat[];
|
|
|
|
extern const tDvbParameterMap SystemValuesTerr[];
|
2010-02-28 12:19:50 +01:00
|
|
|
extern const tDvbParameterMap TransmissionValues[];
|
|
|
|
extern const tDvbParameterMap GuardValues[];
|
|
|
|
extern const tDvbParameterMap HierarchyValues[];
|
|
|
|
extern const tDvbParameterMap RollOffValues[];
|
|
|
|
|
|
|
|
class cDvbTransponderParameters {
|
|
|
|
friend class cDvbSourceParam;
|
|
|
|
private:
|
|
|
|
char polarization;
|
|
|
|
int inversion;
|
|
|
|
int bandwidth;
|
|
|
|
int coderateH;
|
|
|
|
int coderateL;
|
|
|
|
int modulation;
|
|
|
|
int system;
|
|
|
|
int transmission;
|
|
|
|
int guard;
|
|
|
|
int hierarchy;
|
|
|
|
int rollOff;
|
2012-01-11 13:22:51 +01:00
|
|
|
int plpId;
|
2010-02-28 12:19:50 +01:00
|
|
|
int PrintParameter(char *p, char Name, int Value) const;
|
2012-01-11 13:22:51 +01:00
|
|
|
const char *ParseParameter(const char *s, int &Value, const tDvbParameterMap *Map = NULL);
|
2010-02-28 12:19:50 +01:00
|
|
|
public:
|
|
|
|
cDvbTransponderParameters(const char *Parameters = NULL);
|
|
|
|
char Polarization(void) const { return polarization; }
|
|
|
|
int Inversion(void) const { return inversion; }
|
|
|
|
int Bandwidth(void) const { return bandwidth; }
|
|
|
|
int CoderateH(void) const { return coderateH; }
|
|
|
|
int CoderateL(void) const { return coderateL; }
|
|
|
|
int Modulation(void) const { return modulation; }
|
|
|
|
int System(void) const { return system; }
|
|
|
|
int Transmission(void) const { return transmission; }
|
|
|
|
int Guard(void) const { return guard; }
|
|
|
|
int Hierarchy(void) const { return hierarchy; }
|
|
|
|
int RollOff(void) const { return rollOff; }
|
2012-01-11 13:22:51 +01:00
|
|
|
int PlpId(void) const { return plpId; }
|
2010-02-28 12:19:50 +01:00
|
|
|
void SetPolarization(char Polarization) { polarization = Polarization; }
|
|
|
|
void SetInversion(int Inversion) { inversion = Inversion; }
|
|
|
|
void SetBandwidth(int Bandwidth) { bandwidth = Bandwidth; }
|
|
|
|
void SetCoderateH(int CoderateH) { coderateH = CoderateH; }
|
|
|
|
void SetCoderateL(int CoderateL) { coderateL = CoderateL; }
|
|
|
|
void SetModulation(int Modulation) { modulation = Modulation; }
|
|
|
|
void SetSystem(int System) { system = System; }
|
|
|
|
void SetTransmission(int Transmission) { transmission = Transmission; }
|
|
|
|
void SetGuard(int Guard) { guard = Guard; }
|
|
|
|
void SetHierarchy(int Hierarchy) { hierarchy = Hierarchy; }
|
|
|
|
void SetRollOff(int RollOff) { rollOff = RollOff; }
|
2012-01-11 13:22:51 +01:00
|
|
|
void SetPlpId(int PlpId) { plpId = PlpId; }
|
2010-02-28 12:19:50 +01:00
|
|
|
cString ToString(char Type) const;
|
|
|
|
bool Parse(const char *s);
|
|
|
|
};
|
|
|
|
|
2002-12-08 09:55:26 +01:00
|
|
|
class cDvbTuner;
|
|
|
|
|
2002-12-15 15:36:02 +01:00
|
|
|
/// The cDvbDevice implements a DVB device which can be accessed through the Linux DVB driver API.
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
class cDvbDevice : public cDevice {
|
2009-12-31 15:38:18 +01:00
|
|
|
protected:
|
2010-01-04 14:16:11 +01:00
|
|
|
static cString DvbName(const char *Name, int Adapter, int Frontend);
|
|
|
|
static int DvbOpen(const char *Name, int Adapter, int Frontend, int Mode, bool ReportError = false);
|
2002-08-04 14:57:29 +02:00
|
|
|
private:
|
2010-01-04 14:16:11 +01:00
|
|
|
static bool Exists(int Adapter, int Frontend);
|
|
|
|
///< Checks whether the given adapter/frontend exists.
|
|
|
|
static bool Probe(int Adapter, int Frontend);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Probes for existing DVB devices.
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
|
|
|
static bool Initialize(void);
|
2002-12-15 15:36:02 +01:00
|
|
|
///< Initializes the DVB devices.
|
|
|
|
///< Must be called before accessing any DVB functions.
|
|
|
|
///< \return True if any devices are available.
|
2010-01-04 14:16:11 +01:00
|
|
|
protected:
|
|
|
|
int adapter, frontend;
|
2002-08-04 14:57:29 +02:00
|
|
|
private:
|
2008-12-13 12:22:36 +01:00
|
|
|
dvb_frontend_info frontendInfo;
|
2012-01-08 09:27:59 +01:00
|
|
|
int deliverySystems[MAXDELIVERYSYSTEMS];
|
|
|
|
int numDeliverySystems;
|
|
|
|
int numModulations;
|
2009-12-31 15:38:18 +01:00
|
|
|
int fd_dvr, fd_ca;
|
2011-12-04 12:45:26 +01:00
|
|
|
static cMutex bondMutex;
|
|
|
|
cDvbDevice *bondedDevice;
|
|
|
|
mutable bool needsDetachBondedReceivers;
|
2012-01-08 09:27:59 +01:00
|
|
|
bool QueryDeliverySystems(int fd_frontend);
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
2010-01-04 14:16:11 +01:00
|
|
|
cDvbDevice(int Adapter, int Frontend);
|
2002-08-04 14:57:29 +02:00
|
|
|
virtual ~cDvbDevice();
|
2012-01-13 11:41:04 +01:00
|
|
|
int Adapter(void) const { return adapter; }
|
|
|
|
int Frontend(void) const { return frontend; }
|
2005-08-21 08:56:49 +02:00
|
|
|
virtual bool Ready(void);
|
2012-03-13 10:20:42 +01:00
|
|
|
virtual cString DeviceName(void) const;
|
2011-12-04 12:45:26 +01:00
|
|
|
static bool BondDevices(const char *Bondings);
|
|
|
|
///< Bonds the devices as defined in the given Bondings string.
|
|
|
|
///< A bonding is a sequence of device numbers (starting at 1),
|
|
|
|
///< separated by '+' characters. Several bondings are separated by
|
|
|
|
///< commas, as in "1+2,3+4+5".
|
|
|
|
///< Returns false if an error occurred.
|
|
|
|
static void UnBondDevices(void);
|
|
|
|
///< Unbonds all devices.
|
|
|
|
bool Bond(cDvbDevice *Device);
|
|
|
|
///< Bonds this device with the given Device, making both of them use
|
|
|
|
///< the same satellite cable and LNB. Only DVB-S(2) devices can be
|
|
|
|
///< bonded. When this function is called, the calling device must
|
|
|
|
///< not be bonded to any other device. The given Device, however,
|
|
|
|
///< may already be bonded to an other device. That way several devices
|
|
|
|
///< can be bonded together.
|
|
|
|
///< Returns true if the bonding was successful.
|
|
|
|
void UnBond(void);
|
|
|
|
///< Removes this device from any bonding it might have with other
|
|
|
|
///< devices. If this device is not bonded with any other device,
|
|
|
|
///< nothing happens.
|
|
|
|
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 same satellite, polarization
|
|
|
|
///< and band as those the bonded devices are tuned to (if any).
|
|
|
|
///< If ConsiderOccupied is true, any bonded devices that are currently
|
|
|
|
///< occupied but not otherwise receiving will cause this function to
|
|
|
|
///< return false.
|
2002-08-04 14:57:29 +02:00
|
|
|
|
2007-01-07 14:46:14 +01:00
|
|
|
// Common Interface facilities:
|
|
|
|
|
|
|
|
private:
|
|
|
|
cCiAdapter *ciAdapter;
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
// Channel facilities
|
|
|
|
|
|
|
|
private:
|
2002-12-08 09:55:26 +01:00
|
|
|
cDvbTuner *dvbTuner;
|
2002-08-04 14:57:29 +02:00
|
|
|
public:
|
2012-01-08 09:27:59 +01:00
|
|
|
virtual bool ProvidesDeliverySystem(int DeliverySystem) const;
|
2002-10-06 10:25:42 +02:00
|
|
|
virtual bool ProvidesSource(int Source) const;
|
2004-01-04 12:30:00 +01:00
|
|
|
virtual bool ProvidesTransponder(const cChannel *Channel) const;
|
2012-03-02 10:19:00 +01:00
|
|
|
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = IDLEPRIORITY, bool *NeedsDetachReceivers = NULL) const;
|
2011-08-26 13:03:14 +02:00
|
|
|
virtual bool ProvidesEIT(void) const;
|
2008-04-12 13:39:12 +02:00
|
|
|
virtual int NumProvidedSystems(void) const;
|
2011-06-02 13:28:42 +02:00
|
|
|
virtual int SignalStrength(void) const;
|
|
|
|
virtual int SignalQuality(void) const;
|
2010-02-06 14:43:42 +01:00
|
|
|
virtual const cChannel *GetCurrentlyTunedTransponder(void) const;
|
2011-12-04 12:45:26 +01:00
|
|
|
virtual bool IsTunedToTransponder(const cChannel *Channel) const;
|
|
|
|
virtual bool MaySwitchTransponder(const cChannel *Channel) const;
|
2002-09-04 17:26:02 +02:00
|
|
|
protected:
|
|
|
|
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
|
2004-01-04 12:30:00 +01:00
|
|
|
public:
|
2004-10-30 15:10:50 +02:00
|
|
|
virtual bool HasLock(int TimeoutMs = 0);
|
2002-08-04 14:57:29 +02:00
|
|
|
|
|
|
|
// PID handle facilities
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool SetPid(cPidHandle *Handle, int Type, bool On);
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// Section filter facilities
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask);
|
2007-10-14 13:11:23 +02:00
|
|
|
virtual void CloseFilter(int Handle);
|
2007-01-13 12:14:51 +01:00
|
|
|
|
|
|
|
// Common Interface facilities:
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual bool HasCi(void);
|
2003-12-22 13:29:24 +01:00
|
|
|
|
2002-10-12 14:29:46 +02:00
|
|
|
// Audio facilities
|
2002-08-04 14:57:29 +02:00
|
|
|
|
|
|
|
protected:
|
2009-12-31 15:38:18 +01:00
|
|
|
static int setTransferModeForDolbyDigital;
|
2005-02-13 14:26:37 +01:00
|
|
|
public:
|
2011-12-04 13:40:52 +01:00
|
|
|
static void SetTransferModeForDolbyDigital(int Mode); // needs to be here for backwards compatibility
|
2006-05-20 10:17:44 +02:00
|
|
|
///< Controls how the DVB device handles Transfer Mode when replaying
|
|
|
|
///< Dolby Digital audio.
|
|
|
|
///< 0 = don't set "audio bypass" in driver/firmware, don't force Transfer Mode
|
|
|
|
///< 1 = set "audio bypass" in driver/firmware, force Transfer Mode (default)
|
|
|
|
///< 2 = don't set "audio bypass" in driver/firmware, force Transfer Mode
|
2002-08-04 14:57:29 +02:00
|
|
|
|
|
|
|
// Receiver facilities
|
|
|
|
|
2002-09-08 09:03:10 +02:00
|
|
|
private:
|
|
|
|
cTSBuffer *tsBuffer;
|
2002-08-04 14:57:29 +02:00
|
|
|
protected:
|
|
|
|
virtual bool OpenDvr(void);
|
|
|
|
virtual void CloseDvr(void);
|
2002-09-08 09:03:10 +02:00
|
|
|
virtual bool GetTSPacket(uchar *&Data);
|
2011-12-04 12:45:26 +01:00
|
|
|
virtual void DetachAllReceivers(void);
|
2002-08-04 14:57:29 +02:00
|
|
|
};
|
|
|
|
|
2009-12-31 15:38:18 +01:00
|
|
|
// A plugin that implements a DVB device derived from cDvbDevice needs to create
|
|
|
|
// a cDvbDeviceProbe derived object on the heap in order to have its Probe()
|
|
|
|
// function called, where it can actually create the appropriate device.
|
|
|
|
// The cDvbDeviceProbe object must be created in the plugin's constructor,
|
|
|
|
// and deleted in its destructor.
|
|
|
|
|
|
|
|
class cDvbDeviceProbe : public cListObject {
|
|
|
|
public:
|
|
|
|
cDvbDeviceProbe(void);
|
|
|
|
virtual ~cDvbDeviceProbe();
|
2011-06-02 13:28:42 +02:00
|
|
|
static uint32_t GetSubsystemId(int Adapter, int Frontend);
|
2010-01-04 14:16:11 +01:00
|
|
|
virtual bool Probe(int Adapter, int Frontend) = 0;
|
2009-12-31 15:38:18 +01:00
|
|
|
///< Probes for a DVB device at the given Adapter and creates the appropriate
|
|
|
|
///< object derived from cDvbDevice if applicable.
|
|
|
|
///< Returns true if a device has been created.
|
|
|
|
};
|
|
|
|
|
|
|
|
extern cList<cDvbDeviceProbe> DvbDeviceProbes;
|
|
|
|
|
2002-08-04 14:57:29 +02:00
|
|
|
#endif //__DVBDEVICE_H
|