Hi All,
A reworked patch is proposed.
In the current state, the DVB-S2 API is quite experimental and all
related fields have been omitted out, for the time being, the reason
being we could not reach a very conclusive state. In such a
circumstance, it would be the best to think that we add the fields to S2
API as and when it is needed.
A very simple program to understand how the API works is attached. There
isn't much of a difference from the earlier test_api.
Thanks to all who helped to get it going.
Thanks,
Manu
NOTE: The S2 related stuff is not yet ready for consumption and hence
only the very basic fields are added.
diff -Naurp multiproto6.orig/linux/drivers/media/dvb/dvb-core/dvb_frontend.c multiproto6/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
--- multiproto6.orig/linux/drivers/media/dvb/dvb-core/dvb_frontend.c 2006-04-29 03:22:23.000000000 +0400
+++ multiproto6/linux/drivers/media/dvb/dvb-core/dvb_frontend.c 2006-05-26 21:23:35.000000000 +0400
@@ -93,7 +93,11 @@ struct dvb_frontend_private {
/* thread/frontend values */
struct dvb_device *dvbdev;
+ /* Legacy datatype, superseded by dvbfe_params */
struct dvb_frontend_parameters parameters;
+ /* dvbfe_params supersedes dvb_frontend_parameters */
+ struct dvbfe_params fe_params;
+ struct dvbfe_info fe_info;
struct dvb_fe_events events;
struct semaphore sem;
struct list_head list_head;
@@ -126,6 +130,58 @@ struct dvb_frontend_private {
static void dvb_frontend_wakeup(struct dvb_frontend *fe);
+struct modcod_table {
+ u32 dvbfe_modcod;
+ u32 dvbfe_modulation;
+ u32 dvbfe_fec;
+};
+
+static struct modcod_table dvbs2_modcod_lookup[] = {
+ { DVBFE_MODCOD_DUMMY_PLFRAME, DVBFE_MOD_UNKNOWN, DVBFE_FEC_UNKNOWN },
+ { DVBFE_MODCOD_QPSK_1_4, DVBFE_MOD_QPSK, DVBFE_FEC_1_4 },
+ { DVBFE_MODCOD_QPSK_1_3, DVBFE_MOD_QPSK, DVBFE_FEC_1_3 },
+ { DVBFE_MODCOD_QPSK_2_5, DVBFE_MOD_QPSK, DVBFE_FEC_2_5 },
+ { DVBFE_MODCOD_QPSK_1_2, DVBFE_MOD_QPSK, DVBFE_FEC_1_2 },
+ { DVBFE_MODCOD_QPSK_3_5, DVBFE_MOD_QPSK, DVBFE_FEC_3_5 },
+ { DVBFE_MODCOD_QPSK_2_3, DVBFE_MOD_QPSK, DVBFE_FEC_2_3 },
+ { DVBFE_MODCOD_QPSK_3_4, DVBFE_MOD_QPSK, DVBFE_FEC_3_4 },
+ { DVBFE_MODCOD_QPSK_4_5, DVBFE_MOD_QPSK, DVBFE_FEC_4_5 },
+ { DVBFE_MODCOD_QPSK_5_6, DVBFE_MOD_QPSK, DVBFE_FEC_5_6 },
+ { DVBFE_MODCOD_QPSK_8_9, DVBFE_MOD_QPSK, DVBFE_FEC_8_9 },
+ { DVBFE_MODCOD_QPSK_9_10, DVBFE_MOD_QPSK, DVBFE_FEC_9_10 },
+ { DVBFE_MODCOD_8PSK_3_5, DVBFE_MOD_8PSK, DVBFE_FEC_3_5 },
+ { DVBFE_MODCOD_8PSK_2_3, DVBFE_MOD_8PSK, DVBFE_FEC_2_3 },
+ { DVBFE_MODCOD_8PSK_3_4, DVBFE_MOD_8PSK, DVBFE_FEC_3_4 },
+ { DVBFE_MODCOD_8PSK_5_6, DVBFE_MOD_8PSK, DVBFE_FEC_5_6 },
+ { DVBFE_MODCOD_8PSK_8_9, DVBFE_MOD_8PSK, DVBFE_FEC_8_9 },
+ { DVBFE_MODCOD_8PSK_9_10, DVBFE_MOD_8PSK, DVBFE_FEC_9_10 },
+ { DVBFE_MODCOD_16APSK_2_3, DVBFE_MOD_16APSK, DVBFE_FEC_2_3 },
+ { DVBFE_MODCOD_16APSK_3_4, DVBFE_MOD_16APSK, DVBFE_FEC_3_4 },
+ { DVBFE_MODCOD_16APSK_4_5, DVBFE_MOD_16APSK, DVBFE_FEC_4_5 },
+ { DVBFE_MODCOD_16APSK_5_6, DVBFE_MOD_16APSK, DVBFE_FEC_5_6 },
+ { DVBFE_MODCOD_16APSK_8_9, DVBFE_MOD_16APSK, DVBFE_FEC_8_9 },
+ { DVBFE_MODCOD_16APSK_9_10, DVBFE_MOD_16APSK, DVBFE_FEC_9_10 },
+ { DVBFE_MODCOD_32APSK_3_4, DVBFE_MOD_32APSK, DVBFE_FEC_3_4 },
+ { DVBFE_MODCOD_32APSK_4_5, DVBFE_MOD_32APSK, DVBFE_FEC_4_5 },
+ { DVBFE_MODCOD_32APSK_5_6, DVBFE_MOD_32APSK, DVBFE_FEC_5_6 },
+ { DVBFE_MODCOD_32APSK_8_9, DVBFE_MOD_32APSK, DVBFE_FEC_8_9 },
+ { DVBFE_MODCOD_32APSK_9_10, DVBFE_MOD_32APSK, DVBFE_FEC_9_10 },
+ { DVBFE_MODCOD_RESERVED_1, DVBFE_MOD_UNKNOWN, DVBFE_FEC_UNKNOWN },
+ { DVBFE_MODCOD_BPSK_1_3, DVBFE_MOD_BPSK, DVBFE_FEC_1_3 },
+ { DVBFE_MODCOD_BPSK_1_4, DVBFE_MOD_BPSK, DVBFE_FEC_1_4 },
+ { DVBFE_MODCOD_RESERVED_2, DVBFE_MOD_UNKNOWN, DVBFE_FEC_UNKNOWN }
+};
+
+void decode_dvbs2_modcod(u32 dvbfe_modcod,
+ enum dvbfe_modulation *modulation,
+ enum dvbfe_fec *fec)
+{
+ BUG_ON(dvbfe_modcod >= ARRAY_SIZE(dvbs2_modcod_lookup));
+ *modulation = dvbs2_modcod_lookup[dvbfe_modcod].dvbfe_modulation;
+ *fec = dvbs2_modcod_lookup[dvbfe_modcod].dvbfe_fec;
+}
+EXPORT_SYMBOL(decode_dvbs2_modcod);
+
static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
{
struct dvb_frontend_private *fepriv = fe->frontend_priv;
@@ -508,7 +564,10 @@ static int dvb_frontend_thread(void *dat
unsigned long timeout;
char name [15];
fe_status_t s;
+ /* Legacy datatype */
struct dvb_frontend_parameters *params;
+ /* Superseding datatype */
+ struct dvbfe_params *fe_params = &fepriv->fe_params;
dprintk("%s\n", __FUNCTION__);
@@ -558,6 +617,20 @@ static int dvb_frontend_thread(void *dat
}
fepriv->reinitialise = 0;
}
+ /* These callbacks do exist for devices that do have their
+ * own tuning algorithms!
+ *
+ * If we don't have search, we don't have track either. But,
+ * being paranoid, we check whether both of them exists.
+ *
+ * In this case the demod/tuner does zigzag internally based
+ * on information from the device itself rather than using a
+ * simple and blind swzigzag.
+ */
+ if (fe->ops->search)
+ fe->ops->search(fe, fe_params);
+ if (fe->ops->track)
+ fe->ops->track(fe, fe_params);
/* do an iteration of the tuning loop */
if (fe->ops->tune) {
diff -Naurp multiproto6.orig/linux/drivers/media/dvb/dvb-core/dvb_frontend.h multiproto6/linux/drivers/media/dvb/dvb-core/dvb_frontend.h
--- multiproto6.orig/linux/drivers/media/dvb/dvb-core/dvb_frontend.h 2006-04-29 03:22:23.000000000 +0400
+++ multiproto6/linux/drivers/media/dvb/dvb-core/dvb_frontend.h 2006-05-26 21:23:49.000000000 +0400
@@ -61,6 +61,61 @@ struct dvb_tuner_info {
u32 bandwidth_step;
};
+enum dvbfe_modcod {
+ DVBFE_MODCOD_DUMMY_PLFRAME = 0,
+ DVBFE_MODCOD_QPSK_1_4,
+ DVBFE_MODCOD_QPSK_1_3,
+ DVBFE_MODCOD_QPSK_2_5,
+ DVBFE_MODCOD_QPSK_1_2,
+ DVBFE_MODCOD_QPSK_3_5,
+ DVBFE_MODCOD_QPSK_2_3,
+ DVBFE_MODCOD_QPSK_3_4,
+ DVBFE_MODCOD_QPSK_4_5,
+ DVBFE_MODCOD_QPSK_5_6,
+ DVBFE_MODCOD_QPSK_8_9,
+ DVBFE_MODCOD_QPSK_9_10,
+ DVBFE_MODCOD_8PSK_3_5,
+ DVBFE_MODCOD_8PSK_2_3,
+ DVBFE_MODCOD_8PSK_3_4,
+ DVBFE_MODCOD_8PSK_5_6,
+ DVBFE_MODCOD_8PSK_8_9,
+ DVBFE_MODCOD_8PSK_9_10,
+ DVBFE_MODCOD_16APSK_2_3,
+ DVBFE_MODCOD_16APSK_3_4,
+ DVBFE_MODCOD_16APSK_4_5,
+ DVBFE_MODCOD_16APSK_5_6,
+ DVBFE_MODCOD_16APSK_8_9,
+ DVBFE_MODCOD_16APSK_9_10,
+ DVBFE_MODCOD_32APSK_3_4,
+ DVBFE_MODCOD_32APSK_4_5,
+ DVBFE_MODCOD_32APSK_5_6,
+ DVBFE_MODCOD_32APSK_8_9,
+ DVBFE_MODCOD_32APSK_9_10,
+ DVBFE_MODCOD_RESERVED_1,
+ DVBFE_MODCOD_BPSK_1_3,
+ DVBFE_MODCOD_BPSK_1_4,
+ DVBFE_MODCOD_RESERVED_2
+};
+
+enum tuner_param {
+ DVBFE_TUNER_FREQUENCY = (1 << 0),
+ DVBFE_TUNER_TUNERSTEP = (1 << 1),
+ DVBFE_TUNER_IFFREQ = (1 << 2),
+ DVBFE_TUNER_BANDWIDTH = (1 << 3),
+ DVBFE_TUNER_REFERENCE_CLK = (1 << 4),
+ DVBFE_TUNER_IQSENSE = (1 << 5),
+ DVBFE_TUNER_DUMMY = (1 << 31)
+};
+
+struct tuner_state {
+ u32 frequency;
+ u32 tunerstep;
+ u32 ifreq;
+ u32 bandwidth;
+ u32 iqsense;
+ s32 reference_clk;
+};
+
struct dvb_tuner_ops {
struct dvb_tuner_info info;
@@ -83,8 +138,8 @@ struct dvb_tuner_ops {
/** These are provided seperately from set_params in order to facilitate silicon
* tuners which require sophisticated tuning loops, controlling each parameter seperately. */
- int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
- int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
+ int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
+ int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
};
struct dvb_frontend_ops {
@@ -125,6 +180,19 @@ struct dvb_frontend_ops {
int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
+ /* These callbacks are based on the superseding IOCTL's */
+ int (*set_params)(struct dvb_frontend *fe, struct dvbfe_params *fe_params);
+ int (*get_params)(struct dvb_frontend *fe, struct dvbfe_params *fe_params);
+ int (*get_info)(struct dvb_frontend *fe, struct dvbfe_info *fe_info);
+ int (*get_events)(struct dvb_frontend *fe, struct dvbfe_events *fe_events);
+ int (*get_delsys)(struct dvb_frontend *fe, enum dvbfe_delsys);
+
+ /* These callbacks are for devices that implement their own
+ * tuning algorithms, rather than a simple swzigzag
+ */
+ int (*search)(struct dvb_frontend *fe, struct dvbfe_params *fe_params);
+ int (*track)(struct dvb_frontend *fe, struct dvbfe_params *fe_params);
+
struct dvb_tuner_ops tuner_ops;
};
@@ -158,4 +226,8 @@ extern void dvb_frontend_reinitialise(st
extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
+extern void decode_dvbs2_modcod(u32 modcod,
+ enum dvbfe_modulation *modulation,
+ enum dvbfe_fec *fec);
+
#endif
diff -Naurp multiproto6.orig/linux/include/linux/dvb/frontend.h multiproto6/linux/include/linux/dvb/frontend.h
--- multiproto6.orig/linux/include/linux/dvb/frontend.h 2006-04-29 03:22:23.000000000 +0400
+++ multiproto6/linux/include/linux/dvb/frontend.h 2006-05-27 01:27:08.000000000 +0400
@@ -274,4 +274,449 @@ struct dvb_frontend_event {
#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
+/*
+ * References:
+ * DVB-S : EN 300 421
+ * DVB-S2: EN 302 307, TR 102 376, EN 301 210
+ * DVB-C : EN 300 429
+ * DVB-T : EN 300 744
+ * DVB-H : EN 300 304
+ * ATSC : A/53A
+ */
+
+/*
+ * Delivery Systems
+ * needs to set/queried for multistandard frontends
+ */
+enum dvbfe_delsys {
+ DVBFE_DELSYS_DVBS = (1 << 0),
+ DVBFE_DELSYS_DSS = (1 << 1),
+ DVBFE_DELSYS_DVBS2 = (1 << 2),
+ DVBFE_DELSYS_DVBC = (1 << 3),
+ DVBFE_DELSYS_DVBT = (1 << 4),
+ DVBFE_DELSYS_DVBH = (1 << 5),
+ DVBFE_DELSYS_ATSC = (1 << 6),
+ DVBFE_DELSYS_DUMMY = (1 << 31)
+};
+#define DVBFE_GET_DELSYS _IOR('o', 82, enum dvbfe_delsys)
+
+/*
+ * Modulation types
+ */
+enum dvbfe_modulation {
+ DVBFE_MOD_IGNORE = (0 << 0),
+ DVBFE_MOD_UNKNOWN = (1 << 0),
+ DVBFE_MOD_BPSK = (1 << 1),
+ DVBFE_MOD_QPSK = (1 << 2),
+ DVBFE_MOD_OQPSK = (1 << 3),
+ DVBFE_MOD_8PSK = (1 << 4),
+ DVBFE_MOD_16APSK = (1 << 5),
+ DVBFE_MOD_32APSK = (1 << 6),
+ DVBFE_MOD_QAM16 = (1 << 7),
+ DVBFE_MOD_QAM32 = (1 << 8),
+ DVBFE_MOD_QAM64 = (1 << 9),
+ DVBFE_MOD_QAM128 = (1 << 10),
+ DVBFE_MOD_QAM256 = (1 << 11),
+ DVBFE_MOD_QAM512 = (1 << 12),
+ DVBFE_MOD_QAM1024 = (1 << 13),
+ DVBFE_MOD_QAMAUTO = (1 << 14),
+ DVBFE_MOD_OFDM = (1 << 15),
+ DVBFE_MOD_COFDM = (1 << 16),
+ DVBFE_MOD_VSB8 = (1 << 17),
+ DVBFE_MOD_VSB16 = (1 << 18),
+ DVBFE_MOD_AUTO = (1 << 31)
+};
+
+/*
+ * FEC (Forward Error Correction) / Puncture Rate
+ * Reed Solomon Error Correction, an implementation
+ * can be found at http://rscode.sourceforge.net
+ */
+enum dvbfe_fec {
+ DVBFE_FEC_IGNORE = (0 << 0),
+ DVBFE_FEC_UNKNOWN = (1 << 0),
+ DVBFE_FEC_1_4 = (1 << 1),
+ DVBFE_FEC_1_3 = (1 << 2),
+ DVBFE_FEC_2_5 = (1 << 3),
+ DVBFE_FEC_1_2 = (1 << 4),
+ DVBFE_FEC_3_5 = (1 << 5),
+ DVBFE_FEC_2_3 = (1 << 6),
+ DVBFE_FEC_3_4 = (1 << 7),
+ DVBFE_FEC_4_5 = (1 << 8),
+ DVBFE_FEC_5_6 = (1 << 9),
+ DVBFE_FEC_6_7 = (1 << 10),
+ DVBFE_FEC_7_8 = (1 << 11),
+ DVBFE_FEC_8_9 = (1 << 12),
+ DVBFE_FEC_9_10 = (1 << 13),
+ DVBFE_FEC_AUTO = (1 << 31)
+};
+
+/*
+ * Frontend Inversion (I/Q Swap)
+ */
+enum dvbfe_inversion {
+ DVBFE_INVERSION_IGNORE = (0 << 0),
+ DVBFE_INVERSION_OFF = (1 << 1),
+ DVBFE_INVERSION_ON = (1 << 2)
+};
+
+/*
+ * DVB-S parameters
+ */
+struct dvbs_params {
+ __u32 symbol_rate;
+
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+
+ __u8 pad[32];
+};
+
+/*
+ * DSS parameters
+ */
+struct dss_params {
+ __u32 symbol_rate;
+
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+
+ __u8 pad[32];
+};
+
+/*
+ * Rolloff Rate (Nyquist Filter Rolloff)
+ * NOTE: DVB-S2 has rates of 0.20, 0.25, 0.35
+ * Values are x100
+ * Applies to DVB-S2
+ */
+enum dvbfe_rolloff {
+ DVBFE_ROLLOFF_35 = (0 << 0),
+ DVBFE_ROLLOFF_25 = (1 << 0),
+ DVBFE_ROLLOFF_20 = (2 << 0),
+ DVBFE_ROLLOFF_UNKNOWN = (3 << 0)
+};
+
+/*
+ * DVB-S2 parameters
+ */
+struct dvbs2_params {
+ __u32 symbol_rate;
+
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+ enum dvbfe_rolloff rolloff;
+
+ /* Informational fields only */
+ __u8 matype_1;
+ __u8 matype_2;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-C parameters
+ */
+struct dvbc_params {
+ __u32 symbol_rate;
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-T Channel bandwidth
+ */
+enum dvbfe_bandwidth {
+ DVBFE_BANDWIDTH_IGNORE = (0 << 0),
+ DVBFE_BANDWIDTH_8_MHZ = (1 << 0),
+ DVBFE_BANDWIDTH_7_MHZ = (1 << 1),
+ DVBFE_BANDWIDTH_6_MHZ = (1 << 2),
+ DVBFE_BANDWIDTH_5_MHZ = (1 << 3),
+ DVBFE_BANDWIDTH_AUTO = (1 << 31)
+};
+
+/*
+ * DVB-T/DVB-H transmission mode
+ */
+enum dvbfe_transmission_mode {
+ DVBFE_TRANSMISSION_MODE_IGNORE = (0 << 0),
+ DVBFE_TRANSMISSION_MODE_2K = (1 << 0),
+ DVBFE_TRANSMISSION_MODE_4K = (1 << 1),
+ DVBFE_TRANSMISSION_MODE_8K = (1 << 2),
+ DVBFE_TRANSMISSION_MODE_AUTO = (1 << 31)
+};
+
+/*
+ * DVB-T/DVB-H Guard interval
+ */
+enum dvbfe_guard_interval {
+ DVBFE_GUARD_INTERVAL_IGNORE = (0 << 0),
+ DVBFE_GUARD_INTERVAL_1_32 = (1 << 1),
+ DVBFE_GUARD_INTERVAL_1_16 = (1 << 2),
+ DVBFE_GUARD_INTERVAL_1_8 = (1 << 3),
+ DVBFE_GUARD_INTERVAL_1_4 = (1 << 4),
+ DVBFE_GUARD_INTERVAL_AUTO = (1 << 31)
+};
+
+/*
+ * DVB-T/DVB-H Hierarchial modulation
+ */
+enum dvbfe_hierarchy {
+ DVBFE_HIERARCHY_IGNORE = (0 << 0),
+ DVBFE_HIERARCHY_OFF = (1 << 0),
+ DVBFE_HIERARCHY_ON = (1 << 1),
+ DVBFE_HIERARCHY_AUTO = (1 << 31)
+};
+
+/*
+ * DVB-T/DVB-H Rolloff's
+ */
+enum dvbfe_alpha {
+ DVBFE_ALPHA_1 = (1 << 0),
+ DVBFE_ALPHA_2 = (1 << 1),
+ DVBFE_ALPHA_4 = (1 << 2)
+};
+
+/*
+ * Stream priority for Hierachial coding
+ */
+enum dvbfe_stream_priority {
+ DVBFE_STREAM_PRIORITY_HP = (0 << 0),
+ DVBFE_STREAM_PRIORITY_LP = (1 << 0)
+};
+
+/*
+ * DVB-T parameters
+ */
+struct dvbt_params {
+ enum dvbfe_modulation constellation;
+ enum dvbfe_bandwidth bandwidth;
+ enum dvbfe_fec code_rate_HP;
+ enum dvbfe_fec code_rate_LP;
+ enum dvbfe_transmission_mode transmission_mode;
+ enum dvbfe_guard_interval guard_interval;
+ enum dvbfe_hierarchy hierarchy;
+ enum dvbfe_alpha alpha;
+ enum dvbfe_stream_priority priority;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-H Interleaver type
+ */
+enum dvbfe_interleaver {
+ DVBFE_INTERLEAVER_IGNORE = (0 << 0),
+ DVBFE_INTERLEAVER_NATIVE = (1 << 0),
+ DVBFE_INTERLEAVER_INDEPTH = (1 << 1),
+ DVBFE_INTERLEAVER_AUTO = (1 << 31)
+};
+
+/*
+ * DVB-H MPE-FEC Indicator
+ */
+enum dvbfe_mpefec {
+ DVBFE_MPEFEC_IGNORE = (0 << 0),
+ DVBFE_MPEFEC_OFF = (1 << 0),
+ DVBFE_MPEFEC_ON = (1 << 1)
+};
+
+/*
+ * DVB-H Timeslicing Indicator
+ */
+enum dvbfe_timeslicing {
+ DVBFE_TIMESLICING_IGNORE = (0 << 0),
+ DVBFE_TIMESLICING_OFF = (1 << 0),
+ DVBFE_TIMESLICING_ON = (1 << 1)
+};
+
+/*
+ * DVB-H parameters
+ */
+struct dvbh_params {
+ enum dvbfe_modulation constellation;
+ enum dvbfe_fec code_rate_HP;
+ enum dvbfe_fec code_rate_LP;
+ enum dvbfe_transmission_mode transmission_mode;
+ enum dvbfe_guard_interval guard_interval;
+ enum dvbfe_hierarchy hierarchy;
+ enum dvbfe_alpha alpha;
+ enum dvbfe_interleaver interleaver;
+ enum dvbfe_mpefec mpefec;
+ enum dvbfe_timeslicing timeslicing;
+ enum dvbfe_stream_priority priority;
+
+ __u32 bandwidth;
+ __u8 pad[32];
+};
+
+/*
+ * ATSC parameters
+ */
+struct atsc_params {
+ enum dvbfe_modulation modulation;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB Frontend Tuning Parameters
+ */
+struct dvbfe_params {
+ __u32 frequency;
+ enum dvbfe_inversion inversion;
+ enum dvbfe_delsys delivery;
+
+ __u8 pad[32];
+
+ union {
+ struct dvbs_params dvbs;
+ struct dss_params dss;
+ struct dvbs2_params dvbs2;
+ struct dvbc_params dvbc;
+ struct dvbt_params dvbt;
+ struct dvbh_params dvbh;
+ struct atsc_params atsc;
+
+ __u8 pad[128];
+ } delsys;
+};
+#define DVBFE_SET_PARAMS _IOW('o', 83, struct dvbfe_params)
+#define DVBFE_GET_PARAMS _IOWR('o', 84, struct dvbfe_params)
+
+/*
+ * DVB-S capability bitfields
+ */
+struct dvbfe_dvbs_info {
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+
+ __u8 pad[32];
+};
+
+/*
+ * DSS capability bitfields
+ */
+struct dvbfe_dss_info {
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-S2 capability bitfields
+ */
+struct dvbfe_dvbs2_info {
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-C capability bitfields
+ */
+struct dvbfe_dvbc_info {
+ enum dvbfe_modulation modulation;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-T capability bitfields
+ */
+struct dvbfe_dvbt_info {
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+ enum dvbfe_transmission_mode transmission_mode;
+ enum dvbfe_guard_interval guard_interval;
+ enum dvbfe_hierarchy hierarchy;
+ enum dvbfe_bandwidth bandwidth;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB-H capability bitfields
+ */
+struct dvbfe_dvbh_info {
+ enum dvbfe_modulation modulation;
+ enum dvbfe_fec fec;
+ enum dvbfe_transmission_mode transmission_mode;
+ enum dvbfe_guard_interval guard_interval;
+ enum dvbfe_hierarchy hierarchy;
+ enum dvbfe_bandwidth bandwidth;
+
+ __u8 pad[32];
+};
+
+/*
+ * ATSC capability bitfields
+ */
+struct dvbfe_atsc_info {
+ enum dvbfe_modulation modulation;
+
+ __u8 pad[32];
+};
+
+/*
+ * DVB Frontend related Information
+ */
+struct dvbfe_info {
+ char name[128];
+
+ /* For Multi Standard tuners, set "delivery"
+ * to the relevant delivery system to retrieve the
+ * relevant delivery system related information.
+ */
+ enum dvbfe_delsys delivery;
+
+ union {
+ struct dvbfe_dvbs_info dvbs;
+ struct dvbfe_dss_info dss;
+ struct dvbfe_dvbs2_info dvbs2;
+ struct dvbfe_dvbc_info dvbc;
+ struct dvbfe_dvbt_info dvbt;
+ struct dvbfe_dvbh_info dvbh;
+ struct dvbfe_atsc_info atsc;
+
+ __u8 pad[128];
+ } delsys;
+
+ __u32 frequency_min;
+ __u32 frequency_max;
+ __u32 frequency_step;
+ __u32 symbol_rate_min;
+ __u32 symbol_rate_max;
+ __u32 symbol_rate_tolerance;
+
+ enum dvbfe_inversion inversion;
+
+ __u8 pad[128];
+};
+#define DVBFE_GET_INFO _IOWR('o', 85, struct dvbfe_info)
+
+enum dvbfe_status {
+ DVBFE_HAS_SIGNAL = (1 << 0), /* something above noise floor */
+ DVBFE_HAS_CARRIER = (1 << 1), /* Signal found */
+ DVBFE_HAS_VITERBI = (1 << 2), /* FEC is stable */
+ DVBFE_HAS_SYNC = (1 << 3), /* SYNC found */
+ DVBFE_HAS_LOCK = (1 << 4), /* OK .. */
+ DVBFE_TIMEDOUT = (1 << 5), /* no lock in last ~2 s */
+ DVBFE_STATUS_DUMMY = (1 << 31)
+};
+
+/*
+ * DVB Frontend events
+ */
+struct dvbfe_events {
+ enum dvbfe_status status;
+
+ __u8 pad[32];
+};
+#define DVBFE_GET_EVENTS _IOR('o', 86, struct dvbfe_events)
+
#endif /*_DVBFRONTEND_H_*/
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "frontend.h"
int get_info(int fd, struct dvbfe_info *info)
{
if (ioctl(fd, DVBFE_GET_INFO, info) < 0) {
fprintf(stderr, "Error getting device info\n");
return -1;
}
return 0;
}
int get_system(int fd, enum dvbfe_delsys *delsys)
{
if (ioctl(fd, DVBFE_GET_DELSYS, delsys) < 0) {
fprintf(stderr, "Error getting current delivery system\n");
return -1;
}
return 0;
}
int set_params(int fd, struct dvbfe_params *params)
{
if (ioctl(fd, DVBFE_SET_PARAMS, params) < 0) {
fprintf(stderr, "Error setting frontend parameters\n");
return -1;
}
return 0;
}
int get_params(int fd, struct dvbfe_params *params)
{
if (ioctl(fd, DVBFE_GET_PARAMS, params) < 0) {
fprintf(stderr, "Error retreiving frontend parameters\n");
return -1;
}
return 0;
}
int main(void)
{
int fd;
struct dvbfe_info info;
enum dvbfe_delsys delsys;
struct dvbfe_params params;
int system = DVBFE_DELSYS_DVBS;
char *fe = "/dev/dvb/adapter0/frontend0";
if (fd = open(fe, O_RDWR) < 0) {
fprintf(stderr, "Error Opening device\n");
return -1;
}
/* Get all supported delivery systems */
get_info(fd, &info);
fprintf(stderr, "[%s] supported Systems: ", info.name,
info.delivery & DVBFE_DELSYS_DVBS ? "DVB-S " : "",
info.delivery & DVBFE_DELSYS_DSS ? "DSS " : "",
info.delivery & DVBFE_DELSYS_DVBS2 ? "DVB-S2 " : "",
info.delivery & DVBFE_DELSYS_DVBC ? "DVB-C " : "",
info.delivery & DVBFE_DELSYS_DVBT ? "DVB-T " : "",
info.delivery & DVBFE_DELSYS_DVBH ? "DVB-H " : "",
info.delivery & DVBFE_DELSYS_ATSC ? "ATSC " : "", "\n");
switch (system) {
case DVBFE_DELSYS_DVBS:
/* Get DVB-S specific info */
info.delivery = DVBFE_DELSYS_DVBS;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulations: ", info.name,
info.delsys.dvbs.modulation & DVBFE_MOD_BPSK ? "BPSK " : "",
info.delsys.dvbs.modulation & DVBFE_MOD_QPSK ? "QPSK " : "", "\n");
fprintf(stderr, "[%s] supported FEC's: ", info.name,
info.delsys.dvbs.fec & DVBFE_FEC_1_2 ? "FEC 1/2 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_2_3 ? "FEC 2/3 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_3_4 ? "FEC 3/4 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_4_5 ? "FEC 4/5 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_5_6 ? "FEC 5/6 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_6_7 ? "FEC 6/7 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_7_8 ? "FEC 7/8 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_8_9 ? "FEC 8/9 " : "",
info.delsys.dvbs.fec & DVBFE_FEC_AUTO ? "FEC AUTO " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DVB-S */
set_params(fd, ¶ms);
/* Get parameters for DVB-S */
get_params(fd, ¶ms);
break;
case DVBFE_DELSYS_DSS:
/* Get DSS specific info */
info.delivery = DVBFE_DELSYS_DSS;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulations: ", info.name,
info.delsys.dss.modulation & DVBFE_MOD_BPSK ? "BPSK " : "",
info.delsys.dss.modulation & DVBFE_MOD_QPSK ? "QPSK " : "", "\n");
fprintf(stderr, "[%s] supported FEC's: ", info.name,
info.delsys.dss.fec & DVBFE_FEC_1_2 ? "FEC 1/2 " : "",
info.delsys.dss.fec & DVBFE_FEC_2_3 ? "FEC 2/3 " : "",
info.delsys.dss.fec & DVBFE_FEC_3_4 ? "FEC 3/4 " : "",
info.delsys.dss.fec & DVBFE_FEC_4_5 ? "FEC 4/5 " : "",
info.delsys.dss.fec & DVBFE_FEC_5_6 ? "FEC 5/6 " : "",
info.delsys.dss.fec & DVBFE_FEC_6_7 ? "FEC 6/7 " : "",
info.delsys.dss.fec & DVBFE_FEC_7_8 ? "FEC 7/8 " : "",
info.delsys.dss.fec & DVBFE_FEC_8_9 ? "FEC 8/9 " : "",
info.delsys.dss.fec & DVBFE_FEC_AUTO ? "FEC AUTO " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DSS */
set_params(fd, ¶ms);
/* Get parameters for DSS */
get_params(fd, ¶ms);
break;
case DVBFE_DELSYS_DVBS2:
/* Get DVB-S2 specific info */
info.delivery = DVBFE_DELSYS_DVBS2;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulations: ", info.name,
info.delsys.dvbs2.modulation & DVBFE_MOD_BPSK ? "BPSK " : "",
info.delsys.dvbs2.modulation & DVBFE_MOD_QPSK ? "QPSK " : "",
info.delsys.dvbs2.modulation & DVBFE_MOD_8PSK ? "8PSK " : "",
info.delsys.dvbs2.modulation & DVBFE_MOD_16APSK ? "16APSK " : "",
info.delsys.dvbs2.modulation & DVBFE_MOD_32APSK ? "32APSK " : "", "\n");
fprintf(stderr, "[%s] supported FEC's: ", info.name,
info.delsys.dvbs2.fec & DVBFE_FEC_1_4 ? "FEC 1/4 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_1_3 ? "FEC 1/3 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_2_5 ? "FEC 2/5 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_1_2 ? "FEC 1/2 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_3_5 ? "FEC 3/5 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_2_3 ? "FEC 2/3 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_3_4 ? "FEC 3/4 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_4_5 ? "FEC 4/5 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_5_6 ? "FEC 5/6 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_6_7 ? "FEC 6/7 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_7_8 ? "FEC 7/8 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_8_9 ? "FEC 8/9 " : "",
info.delsys.dvbs2.fec & DVBFE_FEC_AUTO ? "FEC AUTO " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DVBS2 */
// Set Rolloff
params.delsys.dvbs2.rolloff = DVBFE_ROLLOFF_35;
set_params(fd, ¶ms);
/* Get parameters for DVBS2 */
get_params(fd, ¶ms);
break;
case DVBFE_DELSYS_DVBC:
/* Get DVB-C specific info */
info.delivery = DVBFE_DELSYS_DVBC;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulation's: ", info.name,
info.delsys.dvbc.modulation & DVBFE_MOD_QAM16 ? "QAM16 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAM32 ? "QAM32 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAM64 ? "QAM64 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAM128 ? "QAM128 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAM256 ? "QAM256 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAM512 ? "QAM512 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAM1024 ? "QAM1024 " : "",
info.delsys.dvbc.modulation & DVBFE_MOD_QAMAUTO ? "QAMAUTO " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DVB-C */
set_params(fd, ¶ms);
/* Get parameters for DVB-C */
get_params(fd, ¶ms);
break;
case DVBFE_DELSYS_DVBT:
/* Get DVB-T specific info */
info.delivery = DVBFE_DELSYS_DVBT;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulations: ", info.name,
info.delsys.dvbt.modulation & DVBFE_MOD_OFDM ? "OFDM " : "",
info.delsys.dvbt.modulation & DVBFE_MOD_COFDM ? "COFDM " : "", "\n");
fprintf(stderr, "[%s] supported Transmission modes: ", info.name,
info.delsys.dvbt.transmission_mode & DVBFE_TRANSMISSION_MODE_2K ? "2k " : "",
info.delsys.dvbt.transmission_mode & DVBFE_TRANSMISSION_MODE_4K ? "4k " : "",
info.delsys.dvbt.transmission_mode & DVBFE_TRANSMISSION_MODE_8K ? "8k " : "",
info.delsys.dvbt.transmission_mode & DVBFE_TRANSMISSION_MODE_AUTO ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supported Guard intervals: ", info.name,
info.delsys.dvbt.guard_interval & DVBFE_GUARD_INTERVAL_1_32 ? "1/32 " : "",
info.delsys.dvbt.guard_interval & DVBFE_GUARD_INTERVAL_1_16 ? "1/16 " : "",
info.delsys.dvbt.guard_interval & DVBFE_GUARD_INTERVAL_1_8 ? "1/8 " : "",
info.delsys.dvbt.guard_interval & DVBFE_GUARD_INTERVAL_1_4 ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supported hierarchy: ", info.name,
info.delsys.dvbt.hierarchy & DVBFE_HIERARCHY_OFF ? "OFF " : "",
info.delsys.dvbt.hierarchy & DVBFE_HIERARCHY_ON ? "ON " : "",
info.delsys.dvbt.hierarchy & DVBFE_HIERARCHY_AUTO ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supported bandwidths: ", info.name,
info.delsys.dvbt.bandwidth & DVBFE_BANDWIDTH_8_MHZ ? "8 MHZ " : "",
info.delsys.dvbt.bandwidth & DVBFE_BANDWIDTH_7_MHZ ? "7 MHZ " : "",
info.delsys.dvbt.bandwidth & DVBFE_BANDWIDTH_6_MHZ ? "6 MHZ " : "",
info.delsys.dvbt.bandwidth & DVBFE_BANDWIDTH_5_MHZ ? "5 MHZ " : "",
info.delsys.dvbt.bandwidth & DVBFE_BANDWIDTH_AUTO ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DVB-T */
set_params(fd, ¶ms);
/* Get parameters for DVB-T */
get_params(fd, ¶ms);
break;
case DVBFE_DELSYS_DVBH:
/* Get DVB-T specific info */
info.delivery = DVBFE_DELSYS_DVBH;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulations: ", info.name,
info.delsys.dvbh.modulation & DVBFE_MOD_OFDM ? "OFDM " : "",
info.delsys.dvbh.modulation & DVBFE_MOD_COFDM ? "COFDM " : "", "\n");
fprintf(stderr, "[%s] supported Transmision modes: ", info.name,
info.delsys.dvbh.transmission_mode & DVBFE_TRANSMISSION_MODE_2K ? "2k " : "",
info.delsys.dvbh.transmission_mode & DVBFE_TRANSMISSION_MODE_4K ? "4k " : "",
info.delsys.dvbh.transmission_mode & DVBFE_TRANSMISSION_MODE_8K ? "8k " : "",
info.delsys.dvbh.transmission_mode & DVBFE_TRANSMISSION_MODE_AUTO ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supported Guard intervals: ", info.name,
info.delsys.dvbh.guard_interval & DVBFE_GUARD_INTERVAL_1_32 ? "1/32 " : "",
info.delsys.dvbh.guard_interval & DVBFE_GUARD_INTERVAL_1_16 ? "1/16 " : "",
info.delsys.dvbh.guard_interval & DVBFE_GUARD_INTERVAL_1_8 ? "1/8 " : "",
info.delsys.dvbh.guard_interval & DVBFE_GUARD_INTERVAL_1_4 ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supported hierarchy: ", info.name,
info.delsys.dvbh.hierarchy & DVBFE_HIERARCHY_OFF ? "OFF " : "",
info.delsys.dvbh.hierarchy & DVBFE_HIERARCHY_ON ? "ON " : "",
info.delsys.dvbh.hierarchy & DVBFE_HIERARCHY_AUTO ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supported bandwidths: ", info.name,
info.delsys.dvbh.bandwidth & DVBFE_BANDWIDTH_8_MHZ ? "8 MHZ " : "",
info.delsys.dvbh.bandwidth & DVBFE_BANDWIDTH_7_MHZ ? "7 MHZ " : "",
info.delsys.dvbh.bandwidth & DVBFE_BANDWIDTH_6_MHZ ? "6 MHZ " : "",
info.delsys.dvbh.bandwidth & DVBFE_BANDWIDTH_5_MHZ ? "5 MHZ " : "",
info.delsys.dvbh.bandwidth & DVBFE_BANDWIDTH_AUTO ? "AUTO " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DVB-H */
set_params(fd, ¶ms);
/* Get parameters for DVB-H */
get_params(fd, ¶ms);
break;
case DVBFE_DELSYS_ATSC:
info.delivery = DVBFE_DELSYS_ATSC;
get_info(fd, &info);
fprintf(stderr, "[%s] supported Modulations: ", info.name,
info.delsys.atsc.modulation & DVBFE_MOD_VSB8 ? "VSB8 " : "",
info.delsys.atsc.modulation & DVBFE_MOD_VSB16 ? "VSB16 " : "",
info.delsys.atsc.modulation & DVBFE_MOD_QAM16 ? "QAM16 " : "",
info.delsys.atsc.modulation & DVBFE_MOD_QAM32 ? "QAM32 " : "",
info.delsys.atsc.modulation & DVBFE_MOD_QAM64 ? "QAM64 " : "",
info.delsys.atsc.modulation & DVBFE_MOD_QAM128 ? "QAM128 " : "",
info.delsys.atsc.modulation & DVBFE_MOD_QAM256 ? "QAM256 " : "", "\n");
fprintf(stderr, "[%s] supports Freq min:%d Freq max:%d, Symbol Rate min:%d Symbol Rate max:%d Symbol rate Tolerance:%d\n",
info.name, info.frequency_min, info.frequency_max, info.symbol_rate_min, info.symbol_rate_max, info.symbol_rate_tolerance);
/* Get current delivery system (optional) */
get_system(fd, &delsys);
/* Set parameters for DVB-H */
set_params(fd, ¶ms);
/* Get parameters for DVB-H */
get_params(fd, ¶ms);
break;
default:
break;
}
close(fd);
return 0;
}
_______________________________________________
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb