[PATCH] add DVB-S2 support to frontend.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this patch is adding dvb-s2 support to frontend.h

From: Marcel Siegert <mws@xxxxxxxxxxx>

changes:
--------------------------------------------------------------------------------------------------
added FE_DVB_S2 as new frontend type;
renamed all other frontend types from modulation to system name;
provided backwards compatibility defines for old apps;
--------------------------------------------------------------------------------------------------
added FE_CAN_DVB_S2 to fe_caps;
added FE_HAS_EXTENDED_CAN_VALUES to fe_caps
      - this flag set signals that new introduced ioctl FE_GET_EXTENDED_INFO is available,
        and fec / modulation / misc flags can be queried using it.

to provide this functionallity i did a backport of API V4 enumerations.
in detail these are
- dvb_fe_code_rate
- dvb_fe_modulation
- dvb_fe_common_cap
- dvb_fe_other_cap

they give us plenty room for further upcoming modulations and features that must be handled/queried.

they have been modified to have the topmost value kept at 1<<31 so it should be guaranteed,
even if we add values, from start to end 32 bits will be used as internal representation for the enums.

they can be queried passing the FE_GET_EXTENDED_INFO a dvb_fe_caps_extended struct;
all 4 groups of enumerations are returned at once.
as they were split up, we still have room for more enumeration values.

there's still room to have e.g. FE_CAN_DVB_T2, FE_CAN_DVB_C2 within the normal and wellknown
fe_caps enumeration scheme.
--------------------------------------------------------------------------------------------------
added fe_rolloff_factor enumerations, they are needed by DVB-S2 tuning parameters
--------------------------------------------------------------------------------------------------
renamed dvb_XXXX_parameters to match system not modulation type.
added/provided backwards compatible defines
renamed dvb_frontend_parameters struct names to match renamed dvb_XXXX_parameters
--------------------------------------------------------------------------------------------------
added dvb_dvbs2_parameters struct to take dvb-s2 tuning parameters
--------------------------------------------------------------------------------------------------
added dvb_frontend_parameters_extended struct,
this one will be used for dvb-s2 and upcoming tuning structs merged in a union.
--------------------------------------------------------------------------------------------------
renamed dvb_frontend_parameters to __dvb_frontend_parameters_old;
renamed ioctls: FE_SET_FRONTEND and FE_GET_FRONTEND to __FE_SET_FRONTEND_OLD and __FE_GET_FRONTEND_OLD;
this is done like in net.h to keep backwards binary compatibility.
--------------------------------------------------------------------------------------------------
added ioctls: FE_SET_FRONTEND and FE_GET_FRONTEND
added struct: dvb_frontend_parameters, that are slightly different from
 the renamed old ones. there a two fields added, type and a pointer to the dvb_frontend_parameters_extended.
 though it stored as a pointer we won't have any conflicts, like we had with dvb-s2, in the future.

for backwards source compatibility old struct is integrated in the new one.
--------------------------------------------------------------------------------------------------
renamed dvb_frontend_event to __dvb_frontend_event_old
as this keeps a struct with the __dvb_frontend_parameters_old
--------------------------------------------------------------------------------------------------
added dvb_frontend_event - binary compatibility through having same first members
as __dvb_frontend_event_old.
added type flag and dvb_frontend_parameters_extended as a pointer for the extended tuning data.
first use is dvb-s2 (dvb_dvbs2_parameters struct);
--------------------------------------------------------------------------------------------------
added dvb_api_version struct, holding a each 16-bit wide major and minor version.
--------------------------------------------------------------------------------------------------
added FE_GET_APIVERSION ioctl - query the actual kernel api version using dvb_api_version struct.
this is necessary to get the ability to write userspace applications/encapsulations/libraries
for different api versions that can handle changes and map between apis.
--------------------------------------------------------------------------------------------------
renamed FE_GET_EVENT ioctl to __FE_GET_EVENT_OLD
backwards binary compatibility reasons (see above)
--------------------------------------------------------------------------------------------------
added FE_EXTENDED_TP (0x80) as fe_status_t enumeration flag.
--------------------------------------------------------------------------------------------------
added FE_GET_EVENT ioctl to receive a dvb_frontend_event struct. as this one is
source compatible to prior versions it signals via the FE_EXTENDED_TP flag in fe_status_t, that a
dvb_frontend_parameters_extended struct is also returned.
to determine type of the extended struct (e.g. dvb-s2) the type was also added as struct member.
--------------------------------------------------------------------------------------------------

that's it a least. i do know that is it more than a "workaround for dvb-s2" and that it maybe seems
to be ugly.
i discussed long times on irc with felix, manu, andrew, and mike, how to keep source and binary
backwards compatibility. i hope i reached that.

please do not hesitate to send comments if i missed a case.

best regards
marcel


Signed-off-by: Marcel Siegert <mws@xxxxxxxxxxx>
--- ../../../../../../v4l-dvb/linux/include/linux/dvb/frontend.h	2006-02-27 01:36:46.117934750 +0100
+++ frontend.h	2006-02-27 20:43:45.600403500 +0100
@@ -30,12 +30,16 @@
 
 
 typedef enum fe_type {
-	FE_QPSK,
-	FE_QAM,
-	FE_OFDM,
-	FE_ATSC
+	FE_DVB_S,
+	FE_DVB_C,
+	FE_DVB_T,
+	FE_ATSC,
+	FE_DVB_S2
 } fe_type_t;
 
+#define FE_QPSK	FE_DVB_S
+#define FE_QAM	FE_DVB_C
+#define FE_OFDM	FE_DVB_T
 
 typedef enum fe_caps {
 	FE_IS_STUPID			= 0,
@@ -62,12 +66,13 @@
 	FE_CAN_HIERARCHY_AUTO		= 0x100000,
 	FE_CAN_8VSB			= 0x200000,
 	FE_CAN_16VSB			= 0x400000,
+	FE_CAN_DVB_S2			= 0x1000000,
+	FE_HAS_EXTENDED_CAN_VALUES	= 0x10000000,
 	FE_NEEDS_BENDING		= 0x20000000, // not supported anymore, don't use (frontend requires frequency bending)
 	FE_CAN_RECOVER			= 0x40000000, // frontend can recover from a cable unplug automatically
 	FE_CAN_MUTE_TS			= 0x80000000  // frontend can stop spurious TS data output
 } fe_caps_t;
 
-
 struct dvb_frontend_info {
 	char       name[128];
 	fe_type_t  type;
@@ -82,6 +87,69 @@
 	fe_caps_t  caps;
 };
 
+/* backport from dvb-api v4 - adapted a bit to have the last value at bit 31 so we */
+/* guarantee that the enum will normally have 32 bits size */
+/*! describes the available forward error correction code rates. */
+enum dvb_fe_code_rate {
+	DVB_FE_FEC_NONE = (1 << 0),
+	DVB_FE_FEC_1_2  = (1 << 1),
+	DVB_FE_FEC_2_3  = (1 << 2),
+	DVB_FE_FEC_3_4  = (1 << 3),
+	DVB_FE_FEC_4_5  = (1 << 4),
+	DVB_FE_FEC_5_6  = (1 << 5),
+	DVB_FE_FEC_6_7  = (1 << 6),
+	DVB_FE_FEC_7_8  = (1 << 7),
+	DVB_FE_FEC_8_9  = (1 << 8),
+	DVB_FE_FEC_3_5	= (1 << 9),
+	DVB_FE_FEC_9_10	= (1 << 10),
+	DVB_FE_FEC_AUTO = (1 << 31)
+};
+
+/*! describes the available modulation types. */
+enum dvb_fe_modulation {
+	DVB_FE_MOD_QPSK		= (1 << 0),
+	DVB_FE_MOD_QAM_16	= (1 << 1),
+	DVB_FE_MOD_QAM_32	= (1 << 2),
+	DVB_FE_MOD_QAM_64	= (1 << 3),
+	DVB_FE_MOD_QAM_128	= (1 << 4),
+	DVB_FE_MOD_QAM_256	= (1 << 5),
+	DVB_FE_MOD_QAM_AUTO	= (1 << 6),
+	DVB_FE_MOD_2_VSB	= (1 << 7),
+	DVB_FE_MOD_4_VSB	= (1 << 8),
+	DVB_FE_MOD_8_VSB	= (1 << 9),
+	DVB_FE_MOD_16_VSB	= (1 << 10),
+	DVB_FE_MOD_8_PSK	= (1 << 11),
+	DVB_FE_MOD_BPSK		= (1 << 12),
+	DVB_FE_MOD_MOD_UNKNOWN	= (1 << 31)
+};
+
+/*! describes common supported frontend capabilities. */
+enum dvb_fe_common_cap {
+	DVB_FE_CAN_INVERSION_AUTO   = (1 << 0), /*!< fixme */
+	DVB_FE_CAN_RECOVER          = (1 << 1), /*!< frontend can recover from a cable unplug automatically */
+	DVB_FE_CAN_MUTE_TS          = (1 << 2), /*!< frontend can stop spurious TS data output */
+	DVB_FE_SUP_HIGH_LNB_VOLTAGE = (1 << 31), /*!< fixme, frontend can deliver higher lnb voltages */
+};
+
+/*! describes other available, frontend type dependent capabilities. */
+enum dvb_fe_other_cap {
+	DVB_FE_CAN_TRANSMISSION_MODE_AUTO = (1 << 0), /*!< fixme (DVB-T specific) */
+	DVB_FE_CAN_BANDWIDTH_AUTO         = (1 << 1), /*!< fixme (DVB-T specific) */
+	DVB_FE_CAN_GUARD_INTERVAL_AUTO    = (1 << 2), /*!< fixme (DVB-T specific) */
+	DVB_FE_CAN_HIERARCHY_AUTO         = (1 << 31), /*!< fixme (DVB-T specific) */
+};
+
+/**
+ *  this struct will be filled by the FE_GET_EXTENDED_INFO ioctl.
+ *  it is a extension to the normal frontend capabilities and provided
+ *  if the dvb_fe_info.caps is having the FE_HAS_EXTENDED_CAN_VALUES bit set.
+ */
+struct dvb_fe_caps_extended {
+	enum dvb_fe_code_rate  caps_fec;        /*!< supported fecs */
+	enum dvb_fe_modulation caps_modulation; /*!< supported modulations */
+	enum dvb_fe_common_cap caps_common;     /*!< supported common capabilities */
+	enum dvb_fe_other_cap  caps_other;      /*!< supported other capabilities*/
+};
 
 /**
  *  Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
@@ -126,7 +194,8 @@
 	FE_HAS_SYNC	= 0x08,   /*  found sync bytes  */
 	FE_HAS_LOCK	= 0x10,   /*  everything's working... */
 	FE_TIMEDOUT	= 0x20,   /*  no lock within the last ~2 seconds */
-	FE_REINIT	= 0x40    /*  frontend was reinitialized,  */
+	FE_REINIT	= 0x40,   /*  frontend was reinitialized,  */
+	FE_EXTENDED_TP  = 0x80    /*  providing new informations */
 } fe_status_t;			  /*  application is recommended to reset */
 				  /*  DiSEqC, tone and parameters */
 
@@ -163,6 +232,12 @@
 	VSB_16
 } fe_modulation_t;
 
+typedef enum fe_rolloff_factor {
+	ROLLOFF_ALPHA_0_35,
+	ROLLOFF_ALPHA_0_25,
+	ROLLOFF_ALPHA_0_20
+} fe_rolloff_factor_t;
+
 typedef enum fe_transmit_mode {
 	TRANSMISSION_MODE_2K,
 	TRANSMISSION_MODE_8K,
@@ -195,12 +270,12 @@
 } fe_hierarchy_t;
 
 
-struct dvb_qpsk_parameters {
+struct dvb_dvbs_parameters {
 	__u32		symbol_rate;  /* symbol rate in Symbols per second */
 	fe_code_rate_t	fec_inner;    /* forward error correction (see above) */
 };
 
-struct dvb_qam_parameters {
+struct dvb_dvbc_parameters {
 	__u32		symbol_rate; /* symbol rate in Symbols per second */
 	fe_code_rate_t	fec_inner;   /* forward error correction (see above) */
 	fe_modulation_t	modulation;  /* modulation type (see above) */
@@ -210,7 +285,7 @@
 	fe_modulation_t	modulation;  /* modulation type (see above) */
 };
 
-struct dvb_ofdm_parameters {
+struct dvb_dvbt_parameters {
 	fe_bandwidth_t      bandwidth;
 	fe_code_rate_t      code_rate_HP;  /* high priority stream code rate */
 	fe_code_rate_t      code_rate_LP;  /* low priority stream code rate */
@@ -220,25 +295,74 @@
 	fe_hierarchy_t      hierarchy_information;
 };
 
+struct dvb_dvbs2_parameters {
+	__u32			symbol_rate;    /* symbol rate in Symbols per second */
+	fe_code_rate_t		fec_inner;      /* forward error correction (see above) */
+	fe_rolloff_factor_t	rolloff_factor; /* rolloff factor needed for dvb-s2 */
+	fe_modulation_t		modulation; /* modulation type (see above) */
+};
+
+#define dvb_qpsk_parameters dvb_dvbs_parameters
+#define dvb_qam_parameters dvb_dvbc_parameters
+#define dvb_ofdm_parameters dvb_dvbt_parameters
+
+/* just kept for backwards source/binary compatibility */
+struct __dvb_frontend_parameters_old {
+	__u32 frequency;     /* (absolute) frequency in Hz for QAM/OFDM/ATSC */
+			     /* intermediate frequency in kHz for QPSK */
+	fe_spectral_inversion_t inversion;
+	union {
+		struct dvb_dvbs_parameters qpsk;
+		struct dvb_dvbc_parameters  qam;
+		struct dvb_dvbt_parameters ofdm;
+		struct dvb_vsb_parameters vsb;
+	} u;
+};
+
+struct dvb_frontend_parameters_extended {
+	union {
+		struct dvb_dvbs2_parameters qpsk2;
+	} xu;
+};
 
 struct dvb_frontend_parameters {
+{
 	__u32 frequency;     /* (absolute) frequency in Hz for QAM/OFDM/ATSC */
 			     /* intermediate frequency in kHz for QPSK */
 	fe_spectral_inversion_t inversion;
 	union {
-		struct dvb_qpsk_parameters qpsk;
-		struct dvb_qam_parameters  qam;
-		struct dvb_ofdm_parameters ofdm;
+		struct dvb_dvbs_parameters qpsk;
+		struct dvb_dvbc_parameters  qam;
+		struct dvb_dvbt_parameters ofdm;
 		struct dvb_vsb_parameters vsb;
 	} u;
+	/* next is new as previous union was just kept to gain source/binary backwards compatibility */
+	fe_type_t type;	     /* select which kind of parameters is within the union u. from frontendtype */
+        struct dvb_frontend_parameters_internal* extended_parameters;
 };
 
+struct __dvb_frontend_event_old {
+	fe_status_t status;
+	struct __dvb_frontend_parameters_old parameters;
+};
 
 struct dvb_frontend_event {
-	fe_status_t status;
-	struct dvb_frontend_parameters parameters;
+	fe_status_t status;					/* if Bit 7 (0x80) FE_EXTENDED_TP is SET - you may safely query type and */
+	struct __dvb_frontend_parameters_old parameters;        /* the extended_parameters */
+	fe_type_t type; 					/* reflect what type of parameters is contained */
+	struct dvb_frontend_parameters* extended_parameters;
 };
 
+/**
+ * Struct to keep the api version which can be queried
+ * via the FE_GET_API_VERSION ioctl.
+ * Need for having encapsulation libraries in userspace
+ * possible.
+ */
+struct dvb_api_version {
+	__u16	major;
+	__u16	minor;
+};
 
 /**
  * When set, this flag will disable any zigzagging or other "normal" tuning
@@ -267,9 +391,30 @@
 #define FE_READ_SNR		   _IOR('o', 72, __u16)
 #define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
 
-#define FE_SET_FRONTEND		   _IOW('o', 76, struct dvb_frontend_parameters)
-#define FE_GET_FRONTEND		   _IOR('o', 77, struct dvb_frontend_parameters)
+#define FE_SET_FRONTEND   	   _IOW('o', 76, struct dvb_frontend_parameters)
+#define FE_GET_FRONTEND            _IOR('o', 77, struct dvb_frontend_parameters)
+#define __FE_SET_FRONTEND_OLD	   _IOW('o', 76, struct __dvb_frontend_parameters_old)
+#define __FE_GET_FRONTEND_OLD	   _IOR('o', 77, struct __dvb_frontend_parameters_old)
 #define FE_SET_FRONTEND_TUNE_MODE  _IO('o', 81) /* unsigned int */
+
+/**
+ * use to set the FE_STANDARD - if a tuner supports more than one type. e.g. DVB-C/T or DVB-S/S2 combi frontends
+ * after FE_SET_STANDARD was set, the drivers has to make sure still to reflect the standards available, but
+ * capabilities should be adjusted to the selected stanadard
+ */
+#define FE_SET_STANDARD		   _IO('o', 82) /* fe_type_t */
+
+/** 
+ * if called return the current frontend api version 
+ */
+#define FE_GET_APIVERSION	   _IOR('o', 83, struct dvb_api_version)
+
+/** 
+ * used to query the api v4 backported capabilities (see above for details)
+ */
+#define FE_GET_EXTENDED_INFO	   _IOR('o', 84, struct dvb_fe_caps_extended)
+
+#define __FE_GET_EVENT_OLD	   _IOR('o', 78, struct __dvb_frontend_event_old)
 #define FE_GET_EVENT		   _IOR('o', 78, struct dvb_frontend_event)
 
 #define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux