*/
#include <sys/types.h>
+#include "dvb-fe-priv.h"
#include "dvb-v5.h"
#include <libdvbv5/dvb-v5-std.h>
-#include <libdvbv5/dvb-fe.h>
#include <inttypes.h>
#include <math.h>
#include <stddef.h>
#include <unistd.h>
-static void dvb_v5_free(struct dvb_v5_fe_parms *parms)
+static void dvb_v5_free(struct dvb_v5_fe_parms_priv *parms)
{
if (parms->fname)
free(parms->fname);
free(parms);
}
-static struct dvb_v5_fe_parms dummy_fe;
struct dvb_v5_fe_parms *dvb_fe_dummy()
{
- dummy_fe.logfunc = dvb_default_log;
- return &dummy_fe;
+ struct dvb_v5_fe_parms_priv *parms = NULL;
+
+ parms = calloc(sizeof(*parms), 1);
+ if (!parms)
+ return NULL;
+ parms->p.logfunc = dvb_default_log;
+ return &parms->p;
}
struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend, unsigned verbose,
int fd, i, r;
char *fname;
struct dtv_properties dtv_prop;
- struct dvb_v5_fe_parms *parms = NULL;
+ struct dvb_v5_fe_parms_priv *parms = NULL;
r = asprintf(&fname, "/dev/dvb/adapter%i/frontend%i", adapter, frontend);
if (r < 0) {
return NULL;
}
parms->fname = fname;
- parms->verbose = verbose;
+ parms->p.verbose = verbose;
parms->fd = fd;
- parms->sat_number = -1;
- parms->abort = 0;
- parms->logfunc = logfunc;
- parms->lna = LNA_AUTO;
- parms->default_charset = "iso-8859-1";
- parms->output_charset = "utf-8";
-
- if (ioctl(fd, FE_GET_INFO, &parms->info) == -1) {
+ parms->p.default_charset = "iso-8859-1";
+ parms->p.output_charset = "utf-8";
+ parms->p.logfunc = logfunc;
+ parms->p.lna = LNA_AUTO;
+ parms->p.sat_number = -1;
+ parms->p.abort = 0;
+
+ if (ioctl(fd, FE_GET_INFO, &parms->p.info) == -1) {
dvb_perror("FE_GET_INFO");
dvb_v5_free(parms);
close(fd);
}
if (verbose) {
- fe_caps_t caps = parms->info.caps;
+ fe_caps_t caps = parms->p.info.caps;
dvb_log("Device %s (%s) capabilities:",
- parms->info.name, fname);
+ parms->p.info.name, fname);
for (i = 0; i < ARRAY_SIZE(fe_caps_name); i++) {
if (caps & fe_caps_name[i].idx)
dvb_log (" %s", fe_caps_name[i].name);
parms->dvb_prop[0].u.data = 0x300;
parms->dvb_prop[1].u.data = SYS_UNDEFINED;
}
- parms->version = parms->dvb_prop[0].u.data;
- parms->current_sys = parms->dvb_prop[1].u.data;
+ parms->p.version = parms->dvb_prop[0].u.data;
+ parms->p.current_sys = parms->dvb_prop[1].u.data;
if (verbose)
dvb_log ("DVB API Version %d.%d%s, Current v5 delivery system: %s",
- parms->version / 256,
- parms->version % 256,
+ parms->p.version / 256,
+ parms->p.version % 256,
use_legacy_call ? " (forcing DVBv3 calls)" : "",
- delivery_system_name[parms->current_sys]);
+ delivery_system_name[parms->p.current_sys]);
- if (parms->version < 0x500)
+ if (parms->p.version < 0x500)
use_legacy_call = 1;
- if (parms->version >= 0x50a)
- parms->has_v5_stats = 1;
+ if (parms->p.version >= 0x50a)
+ parms->p.has_v5_stats = 1;
else
- parms->has_v5_stats = 0;
+ parms->p.has_v5_stats = 0;
- if (use_legacy_call || parms->version < 0x505) {
- parms->legacy_fe = 1;
- switch(parms->info.type) {
+ if (use_legacy_call || parms->p.version < 0x505) {
+ parms->p.legacy_fe = 1;
+ switch(parms->p.info.type) {
case FE_QPSK:
- parms->current_sys = SYS_DVBS;
- parms->systems[parms->num_systems++] = parms->current_sys;
- if (parms->version < 0x0500)
+ parms->p.current_sys = SYS_DVBS;
+ parms->p.systems[parms->p.num_systems++] = parms->p.current_sys;
+ if (parms->p.version < 0x0500)
break;
- if (parms->info.caps & FE_CAN_2G_MODULATION)
- parms->systems[parms->num_systems++] = SYS_DVBS2;
- if (parms->info.caps & FE_CAN_TURBO_FEC)
- parms->systems[parms->num_systems++] = SYS_TURBO;
+ if (parms->p.info.caps & FE_CAN_2G_MODULATION)
+ parms->p.systems[parms->p.num_systems++] = SYS_DVBS2;
+ if (parms->p.info.caps & FE_CAN_TURBO_FEC)
+ parms->p.systems[parms->p.num_systems++] = SYS_TURBO;
break;
case FE_QAM:
- parms->current_sys = SYS_DVBC_ANNEX_A;
- parms->systems[parms->num_systems++] = parms->current_sys;
+ parms->p.current_sys = SYS_DVBC_ANNEX_A;
+ parms->p.systems[parms->p.num_systems++] = parms->p.current_sys;
break;
case FE_OFDM:
- parms->current_sys = SYS_DVBT;
- parms->systems[parms->num_systems++] = parms->current_sys;
- if (parms->version < 0x0500)
+ parms->p.current_sys = SYS_DVBT;
+ parms->p.systems[parms->p.num_systems++] = parms->p.current_sys;
+ if (parms->p.version < 0x0500)
break;
- if (parms->info.caps & FE_CAN_2G_MODULATION)
- parms->systems[parms->num_systems++] = SYS_DVBT2;
+ if (parms->p.info.caps & FE_CAN_2G_MODULATION)
+ parms->p.systems[parms->p.num_systems++] = SYS_DVBT2;
break;
case FE_ATSC:
- if (parms->info.caps & (FE_CAN_8VSB | FE_CAN_16VSB))
- parms->systems[parms->num_systems++] = SYS_ATSC;
- if (parms->info.caps & (FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_QAM_AUTO))
- parms->systems[parms->num_systems++] = SYS_DVBC_ANNEX_B;
- parms->current_sys = parms->systems[0];
+ if (parms->p.info.caps & (FE_CAN_8VSB | FE_CAN_16VSB))
+ parms->p.systems[parms->p.num_systems++] = SYS_ATSC;
+ if (parms->p.info.caps & (FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_QAM_AUTO))
+ parms->p.systems[parms->p.num_systems++] = SYS_DVBC_ANNEX_B;
+ parms->p.current_sys = parms->p.systems[0];
break;
}
- if (!parms->num_systems) {
+ if (!parms->p.num_systems) {
dvb_logerr("delivery system not detected");
dvb_v5_free(parms);
close(fd);
free(fname);
return NULL;
}
- parms->num_systems = parms->dvb_prop[0].u.buffer.len;
- for (i = 0; i < parms->num_systems; i++)
- parms->systems[i] = parms->dvb_prop[0].u.buffer.data[i];
+ parms->p.num_systems = parms->dvb_prop[0].u.buffer.len;
+ for (i = 0; i < parms->p.num_systems; i++)
+ parms->p.systems[i] = parms->dvb_prop[0].u.buffer.data[i];
- if (parms->num_systems == 0) {
+ if (parms->p.num_systems == 0) {
dvb_logerr("driver died while trying to set the delivery system");
dvb_v5_free(parms);
close(fd);
if (verbose) {
dvb_log("Supported delivery system%s: ",
- (parms->num_systems > 1) ? "s" : "");
- for (i = 0; i < parms->num_systems; i++) {
- if (parms->systems[i] == parms->current_sys)
+ (parms->p.num_systems > 1) ? "s" : "");
+ for (i = 0; i < parms->p.num_systems; i++) {
+ if (parms->p.systems[i] == parms->p.current_sys)
dvb_log (" [%s]",
- delivery_system_name[parms->systems[i]]);
+ delivery_system_name[parms->p.systems[i]]);
else
dvb_log (" %s",
- delivery_system_name[parms->systems[i]]);
+ delivery_system_name[parms->p.systems[i]]);
}
- if (use_legacy_call || parms->version < 0x505)
+ if (use_legacy_call || parms->p.version < 0x505)
dvb_log("Warning: new delivery systems like ISDB-T, ISDB-S, DMB-TH, DSS, ATSC-MH will be miss-detected by a DVBv5.4 or earlier API call");
}
/*
* Fix a bug at some DVB drivers
*/
- if (parms->current_sys == SYS_UNDEFINED)
- parms->current_sys = parms->systems[0];
+ if (parms->p.current_sys == SYS_UNDEFINED)
+ parms->p.current_sys = parms->p.systems[0];
/* Prepare to use the delivery system */
- dvb_set_sys(parms, parms->current_sys);
+ dvb_set_sys(&parms->p, parms->p.current_sys);
/*
* Prepare the status struct - DVBv5.10 parameters should
parms->stats.prop[11].cmd = DTV_QUALITY;
parms->stats.prop[12].cmd = DTV_PRE_BER;
- return parms;
+ return &parms->p;
}
}
-void dvb_fe_close(struct dvb_v5_fe_parms *parms)
+void dvb_fe_close(struct dvb_v5_fe_parms *p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
+
if (!parms)
return;
return;
/* Disable LNBf power */
- if (dvb_fe_is_satellite(parms->current_sys))
- dvb_fe_sec_voltage(parms, 0, 0);
+ if (dvb_fe_is_satellite(parms->p.current_sys))
+ dvb_fe_sec_voltage(&parms->p, 0, 0);
close(parms->fd);
return n;
}
-int dvb_set_sys(struct dvb_v5_fe_parms *parms,
- fe_delivery_system_t sys)
+int dvb_set_sys(struct dvb_v5_fe_parms *p, fe_delivery_system_t sys)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
struct dtv_property dvb_prop[1];
struct dtv_properties prop;
int rc;
- if (sys != parms->current_sys) {
+ if (sys != parms->p.current_sys) {
/* Disable LNBf power */
- if (dvb_fe_is_satellite(parms->current_sys) &&
+ if (dvb_fe_is_satellite(parms->p.current_sys) &&
!dvb_fe_is_satellite(sys))
- dvb_fe_sec_voltage(parms, 0, 0);
+ dvb_fe_sec_voltage(&parms->p, 0, 0);
/* Can't change standard with the legacy FE support */
- if (parms->legacy_fe)
+ if (parms->p.legacy_fe)
return EINVAL;
dvb_prop[0].cmd = DTV_DELIVERY_SYSTEM;
if (rc < 0)
return EINVAL;
- parms->current_sys = sys;
+ parms->p.current_sys = sys;
parms->n_props = rc;
return 0;
return status;
}
-int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
+int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *p,
uint32_t desired_system)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int i;
uint32_t delsys = SYS_UNDEFINED;
enum dvbv3_emulation_type type;
/* Check if the desired delivery system is supported */
- for (i = 0; i < parms->num_systems; i++) {
- if (parms->systems[i] == desired_system) {
- dvb_set_sys(parms, desired_system);
+ for (i = 0; i < parms->p.num_systems; i++) {
+ if (parms->p.systems[i] == desired_system) {
+ dvb_set_sys(&parms->p, desired_system);
return 0;
}
}
* Get the last non-DVBv3 delivery system that has the same type
* of the desired system
*/
- for (i = 0; i < parms->num_systems; i++) {
- if ((dvbv3_type(parms->systems[i]) == type) &&
- !is_dvbv3_delsys(parms->systems[i]))
- delsys = parms->systems[i];
+ for (i = 0; i < parms->p.num_systems; i++) {
+ if ((dvbv3_type(parms->p.systems[i]) == type) &&
+ !is_dvbv3_delsys(parms->p.systems[i]))
+ delsys = parms->p.systems[i];
}
if (delsys == SYS_UNDEFINED)
dvb_log("Using a DVBv3 compat file for %s", delivery_system_name[delsys]);
- dvb_set_sys(parms, delsys);
+ dvb_set_sys(&parms->p, delsys);
/* Put ISDB-T into auto mode */
if (delsys == SYS_ISDBT) {
- dvb_fe_store_parm(parms, DTV_BANDWIDTH_HZ, 6000000);
- dvb_fe_store_parm(parms, DTV_ISDBT_PARTIAL_RECEPTION, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_SOUND_BROADCASTING, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_SB_SUBCHANNEL_ID, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_SB_SEGMENT_IDX, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_SB_SEGMENT_COUNT, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYER_ENABLED, 7);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERA_FEC, FEC_AUTO);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERB_FEC, FEC_AUTO);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERC_FEC, FEC_AUTO);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERA_MODULATION, QAM_AUTO);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERB_MODULATION, QAM_AUTO);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERC_MODULATION, QAM_AUTO);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERA_SEGMENT_COUNT, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERA_TIME_INTERLEAVING, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERB_SEGMENT_COUNT, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERB_TIME_INTERLEAVING, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERC_SEGMENT_COUNT, 0);
- dvb_fe_store_parm(parms, DTV_ISDBT_LAYERC_TIME_INTERLEAVING, 0);
+ dvb_fe_store_parm(&parms->p, DTV_BANDWIDTH_HZ, 6000000);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_PARTIAL_RECEPTION, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_SOUND_BROADCASTING, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_SB_SUBCHANNEL_ID, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_SB_SEGMENT_IDX, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_SB_SEGMENT_COUNT, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYER_ENABLED, 7);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERA_FEC, FEC_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERB_FEC, FEC_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERC_FEC, FEC_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERA_MODULATION, QAM_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERB_MODULATION, QAM_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERC_MODULATION, QAM_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERA_SEGMENT_COUNT, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERA_TIME_INTERLEAVING, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERB_SEGMENT_COUNT, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERB_TIME_INTERLEAVING, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERC_SEGMENT_COUNT, 0);
+ dvb_fe_store_parm(&parms->p, DTV_ISDBT_LAYERC_TIME_INTERLEAVING, 0);
}
return 0;
}
return NULL;
}
-void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms)
+void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int i;
for (i = 0; i < parms->n_props; i++) {
}
};
-int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
+int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *p,
unsigned cmd, uint32_t *value)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int i;
for (i = 0; i < parms->n_props; i++) {
if (parms->dvb_prop[i].cmd != cmd)
return EINVAL;
}
-int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
+int dvb_fe_store_parm(struct dvb_v5_fe_parms *p,
unsigned cmd, uint32_t value)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int i;
for (i = 0; i < parms->n_props; i++) {
if (parms->dvb_prop[i].cmd != cmd)
return j;
}
-int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
+int dvb_fe_get_parms(struct dvb_v5_fe_parms *p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int i, n = 0;
const unsigned int *sys_props;
struct dtv_properties prop;
struct dvb_frontend_parameters v3_parms;
uint32_t bw;
- sys_props = dvb_v5_delivery_system[parms->current_sys];
+ sys_props = dvb_v5_delivery_system[parms->p.current_sys];
if (!sys_props)
return EINVAL;
n++;
}
parms->dvb_prop[n].cmd = DTV_DELIVERY_SYSTEM;
- parms->dvb_prop[n].u.data = parms->current_sys;
+ parms->dvb_prop[n].u.data = parms->p.current_sys;
n++;
/* Keep it ready for set */
prop.props = fe_prop;
prop.num = n;
- if (!parms->legacy_fe) {
+ if (!parms->p.legacy_fe) {
if (ioctl(parms->fd, FE_GET_PROPERTY, &prop) == -1) {
dvb_perror("FE_GET_PROPERTY");
return errno;
/* copy back params from temporary fe_prop */
for (i = 0; i < n; i++)
- dvb_fe_store_parm(parms, fe_prop[i].cmd, fe_prop[i].u.data);
+ dvb_fe_store_parm(&parms->p, fe_prop[i].cmd, fe_prop[i].u.data);
- if (parms->verbose) {
+ if (parms->p.verbose) {
dvb_log("Got parameters for %s:",
- delivery_system_name[parms->current_sys]);
- dvb_fe_prt_parms(parms);
+ delivery_system_name[parms->p.current_sys]);
+ dvb_fe_prt_parms(&parms->p);
}
return 0;
}
return -1;
}
- dvb_fe_store_parm(parms, DTV_FREQUENCY, v3_parms.frequency);
- dvb_fe_store_parm(parms, DTV_INVERSION, v3_parms.inversion);
- switch (parms->current_sys) {
+ dvb_fe_store_parm(&parms->p, DTV_FREQUENCY, v3_parms.frequency);
+ dvb_fe_store_parm(&parms->p, DTV_INVERSION, v3_parms.inversion);
+ switch (parms->p.current_sys) {
case SYS_DVBS:
- dvb_fe_store_parm(parms, DTV_SYMBOL_RATE, v3_parms.u.qpsk.symbol_rate);
- dvb_fe_store_parm(parms, DTV_INNER_FEC, v3_parms.u.qpsk.fec_inner);
+ dvb_fe_store_parm(&parms->p, DTV_SYMBOL_RATE, v3_parms.u.qpsk.symbol_rate);
+ dvb_fe_store_parm(&parms->p, DTV_INNER_FEC, v3_parms.u.qpsk.fec_inner);
break;
case SYS_DVBC_ANNEX_A:
- dvb_fe_store_parm(parms, DTV_SYMBOL_RATE, v3_parms.u.qam.symbol_rate);
- dvb_fe_store_parm(parms, DTV_INNER_FEC, v3_parms.u.qam.fec_inner);
- dvb_fe_store_parm(parms, DTV_MODULATION, v3_parms.u.qam.modulation);
+ dvb_fe_store_parm(&parms->p, DTV_SYMBOL_RATE, v3_parms.u.qam.symbol_rate);
+ dvb_fe_store_parm(&parms->p, DTV_INNER_FEC, v3_parms.u.qam.fec_inner);
+ dvb_fe_store_parm(&parms->p, DTV_MODULATION, v3_parms.u.qam.modulation);
break;
case SYS_ATSC:
case SYS_ATSCMH:
case SYS_DVBC_ANNEX_B:
- dvb_fe_store_parm(parms, DTV_MODULATION, v3_parms.u.vsb.modulation);
+ dvb_fe_store_parm(&parms->p, DTV_MODULATION, v3_parms.u.vsb.modulation);
break;
case SYS_DVBT:
if (v3_parms.u.ofdm.bandwidth < ARRAY_SIZE(fe_bandwidth_name) -1)
bw = fe_bandwidth_name[v3_parms.u.ofdm.bandwidth];
else bw = 0;
- dvb_fe_store_parm(parms, DTV_BANDWIDTH_HZ, bw);
- dvb_fe_store_parm(parms, DTV_CODE_RATE_HP, v3_parms.u.ofdm.code_rate_HP);
- dvb_fe_store_parm(parms, DTV_CODE_RATE_LP, v3_parms.u.ofdm.code_rate_LP);
- dvb_fe_store_parm(parms, DTV_MODULATION, v3_parms.u.ofdm.constellation);
- dvb_fe_store_parm(parms, DTV_TRANSMISSION_MODE, v3_parms.u.ofdm.transmission_mode);
- dvb_fe_store_parm(parms, DTV_GUARD_INTERVAL, v3_parms.u.ofdm.guard_interval);
- dvb_fe_store_parm(parms, DTV_HIERARCHY, v3_parms.u.ofdm.hierarchy_information);
+ dvb_fe_store_parm(&parms->p, DTV_BANDWIDTH_HZ, bw);
+ dvb_fe_store_parm(&parms->p, DTV_CODE_RATE_HP, v3_parms.u.ofdm.code_rate_HP);
+ dvb_fe_store_parm(&parms->p, DTV_CODE_RATE_LP, v3_parms.u.ofdm.code_rate_LP);
+ dvb_fe_store_parm(&parms->p, DTV_MODULATION, v3_parms.u.ofdm.constellation);
+ dvb_fe_store_parm(&parms->p, DTV_TRANSMISSION_MODE, v3_parms.u.ofdm.transmission_mode);
+ dvb_fe_store_parm(&parms->p, DTV_GUARD_INTERVAL, v3_parms.u.ofdm.guard_interval);
+ dvb_fe_store_parm(&parms->p, DTV_HIERARCHY, v3_parms.u.ofdm.hierarchy_information);
break;
default:
return -EINVAL;
return 0;
}
-int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms)
+int dvb_fe_set_parms(struct dvb_v5_fe_parms *p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
/* Use a temporary copy of the parameters so we can safely perform
* adjustments for satellite */
- struct dvb_v5_fe_parms tmp_parms = *parms;
+ struct dvb_v5_fe_parms_priv tmp_parms = *parms;
struct dtv_properties prop;
struct dvb_frontend_parameters v3_parms;
uint32_t bw;
- if (parms->lna != LNA_AUTO && !parms->legacy_fe) {
- struct dvb_v5_fe_parms tmp_lna_parms;
+ if (parms->p.lna != LNA_AUTO && !parms->p.legacy_fe) {
+ struct dvb_v5_fe_parms_priv tmp_lna_parms;
memset(&prop, 0, sizeof(prop));
prop.props = tmp_lna_parms.dvb_prop;
prop.props[0].cmd = DTV_LNA;
- prop.props[0].u.data = parms->lna;
+ prop.props[0].u.data = parms->p.lna;
prop.num = 1;
if (ioctl(parms->fd, FE_SET_PROPERTY, &prop) == -1) {
dvb_perror("Setting LNA");
- parms->lna = LNA_AUTO;
- } else if (parms->lna != LNA_AUTO && parms->verbose)
- dvb_logdbg("LNA is %s", parms->lna ? "ON" : "OFF");
+ parms->p.lna = LNA_AUTO;
+ } else if (parms->p.lna != LNA_AUTO && parms->p.verbose)
+ dvb_logdbg("LNA is %s", parms->p.lna ? "ON" : "OFF");
}
- if (dvb_fe_is_satellite(tmp_parms.current_sys))
- dvb_sat_set_parms(&tmp_parms);
+ if (dvb_fe_is_satellite(tmp_parms.p.current_sys))
+ dvb_sat_set_parms(&tmp_parms.p);
/* Filter out any user DTV_foo property such as DTV_POLARIZATION */
- tmp_parms.n_props = dvb_copy_fe_props(tmp_parms.dvb_prop, tmp_parms.n_props, tmp_parms.dvb_prop);
+ tmp_parms.n_props = dvb_copy_fe_props(tmp_parms.dvb_prop,
+ tmp_parms.n_props,
+ tmp_parms.dvb_prop);
memset(&prop, 0, sizeof(prop));
prop.props = tmp_parms.dvb_prop;
prop.props[prop.num].cmd = DTV_TUNE;
prop.num++;
- if (!parms->legacy_fe) {
+ if (!parms->p.legacy_fe) {
if (ioctl(parms->fd, FE_SET_PROPERTY, &prop) == -1) {
dvb_perror("FE_SET_PROPERTY");
- if (parms->verbose)
- dvb_fe_prt_parms(parms);
+ if (parms->p.verbose)
+ dvb_fe_prt_parms(&parms->p);
return -1;
}
return 0;
}
/* DVBv3 call */
- dvb_fe_retrieve_parm(&tmp_parms, DTV_FREQUENCY, &v3_parms.frequency);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_INVERSION, &v3_parms.inversion);
- switch (tmp_parms.current_sys) {
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_FREQUENCY, &v3_parms.frequency);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_INVERSION, &v3_parms.inversion);
+ switch (tmp_parms.p.current_sys) {
case SYS_DVBS:
- dvb_fe_retrieve_parm(&tmp_parms, DTV_SYMBOL_RATE, &v3_parms.u.qpsk.symbol_rate);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_INNER_FEC, &v3_parms.u.qpsk.fec_inner);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_SYMBOL_RATE, &v3_parms.u.qpsk.symbol_rate);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_INNER_FEC, &v3_parms.u.qpsk.fec_inner);
break;
case SYS_DVBC_ANNEX_AC:
- dvb_fe_retrieve_parm(&tmp_parms, DTV_SYMBOL_RATE, &v3_parms.u.qam.symbol_rate);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_INNER_FEC, &v3_parms.u.qam.fec_inner);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_MODULATION, &v3_parms.u.qam.modulation);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_SYMBOL_RATE, &v3_parms.u.qam.symbol_rate);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_INNER_FEC, &v3_parms.u.qam.fec_inner);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_MODULATION, &v3_parms.u.qam.modulation);
break;
case SYS_ATSC:
case SYS_ATSCMH:
case SYS_DVBC_ANNEX_B:
- dvb_fe_retrieve_parm(&tmp_parms, DTV_MODULATION, &v3_parms.u.vsb.modulation);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_MODULATION, &v3_parms.u.vsb.modulation);
break;
case SYS_DVBT:
for (bw = 0; fe_bandwidth_name[bw] != 0; bw++) {
if (fe_bandwidth_name[bw] == v3_parms.u.ofdm.bandwidth)
break;
}
- dvb_fe_retrieve_parm(&tmp_parms, DTV_BANDWIDTH_HZ, &bw);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_CODE_RATE_HP, &v3_parms.u.ofdm.code_rate_HP);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_CODE_RATE_LP, &v3_parms.u.ofdm.code_rate_LP);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_MODULATION, &v3_parms.u.ofdm.constellation);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_TRANSMISSION_MODE, &v3_parms.u.ofdm.transmission_mode);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_GUARD_INTERVAL, &v3_parms.u.ofdm.guard_interval);
- dvb_fe_retrieve_parm(&tmp_parms, DTV_HIERARCHY, &v3_parms.u.ofdm.hierarchy_information);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_BANDWIDTH_HZ, &bw);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_CODE_RATE_HP, &v3_parms.u.ofdm.code_rate_HP);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_CODE_RATE_LP, &v3_parms.u.ofdm.code_rate_LP);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_MODULATION, &v3_parms.u.ofdm.constellation);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_TRANSMISSION_MODE, &v3_parms.u.ofdm.transmission_mode);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_GUARD_INTERVAL, &v3_parms.u.ofdm.guard_interval);
+ dvb_fe_retrieve_parm(&tmp_parms.p, DTV_HIERARCHY, &v3_parms.u.ofdm.hierarchy_information);
break;
default:
return -EINVAL;
}
if (ioctl(tmp_parms.fd, FE_SET_FRONTEND, &v3_parms) == -1) {
dvb_perror("FE_SET_FRONTEND");
- if (tmp_parms.verbose)
- dvb_fe_prt_parms(&tmp_parms);
+ if (tmp_parms.p.verbose)
+ dvb_fe_prt_parms(&tmp_parms.p);
return -1;
}
return 0;
}
-static struct dtv_stats *dvb_fe_store_stats(struct dvb_v5_fe_parms *parms,
+static struct dtv_stats *dvb_fe_store_stats(struct dvb_v5_fe_parms_priv *parms,
unsigned cmd,
enum fecap_scale_params scale,
unsigned layer,
uint32_t value)
{
int i;
+
for (i = 0; i < DTV_NUM_STATS_PROPS; i++) {
if (parms->stats.prop[i].cmd != cmd)
continue;
return NULL;
}
-static float calculate_postBER(struct dvb_v5_fe_parms *parms, unsigned layer)
+static float calculate_postBER(struct dvb_v5_fe_parms_priv *parms, unsigned layer)
{
uint64_t n, d;
return ((float)n)/d;
}
-static float calculate_preBER(struct dvb_v5_fe_parms *parms, unsigned layer)
+static float calculate_preBER(struct dvb_v5_fe_parms_priv *parms, unsigned layer)
{
uint64_t n, d;
return ((float)n)/d;
}
-static struct dtv_stats *dvb_fe_retrieve_v5_BER(struct dvb_v5_fe_parms *parms,
+static struct dtv_stats *dvb_fe_retrieve_v5_BER(struct dvb_v5_fe_parms_priv *parms,
unsigned layer)
{
float ber;
return dvb_fe_store_stats(parms, DTV_BER, FE_SCALE_COUNTER, layer, ber64);
}
-struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
+struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *p,
unsigned cmd, unsigned layer)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int i;
- if (cmd == DTV_BER && parms->has_v5_stats)
+ if (cmd == DTV_BER && parms->p.has_v5_stats)
return dvb_fe_retrieve_v5_BER(parms, layer);
for (i = 0; i < DTV_NUM_STATS_PROPS; i++) {
return NULL;
}
-int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
+int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *p,
unsigned cmd, uint32_t *value)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
struct dtv_stats *stat;
enum fecap_scale_params scale;
- stat = dvb_fe_retrieve_stats_layer(parms, cmd, 0);
+ stat = dvb_fe_retrieve_stats_layer(&parms->p, cmd, 0);
if (!stat) {
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_logdbg("%s not found on retrieve", dvb_cmd_name(cmd));
return EINVAL;
}
scale = stat->scale;
if (scale == FE_SCALE_NOT_AVAILABLE) {
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_logdbg("%s not available", dvb_cmd_name(cmd));
return EINVAL;
}
*value = stat->uvalue;
- if (parms->verbose > 1)
+ if (parms->p.verbose > 1)
dvb_logdbg("Stats for %s = %d", dvb_cmd_name(cmd), *value);
return 0;
}
-float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
+float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *p, unsigned layer,
enum fecap_scale_params *scale)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
float ber;
uint32_t ber32;
- if (parms->has_v5_stats) {
+ if (parms->p.has_v5_stats) {
ber = calculate_postBER(parms, layer);
if (ber >= 0)
*scale = FE_SCALE_COUNTER;
return -1;
}
- if (dvb_fe_retrieve_stats(parms, DTV_BER, &ber32))
+ if (dvb_fe_retrieve_stats(&parms->p, DTV_BER, &ber32))
*scale = FE_SCALE_NOT_AVAILABLE;
else
*scale = FE_SCALE_RELATIVE;
return ber32;
}
-float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer)
+float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *p, unsigned layer)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
uint64_t n, d;
if (!parms->stats.has_per[layer]) {
{ QAM_64, FEC_7_8, 22.0, 24.0},
};
-static enum dvb_quality dvbv_fe_cnr_to_quality(struct dvb_v5_fe_parms *parms,
+static enum dvb_quality dvbv_fe_cnr_to_quality(struct dvb_v5_fe_parms_priv *parms,
struct dtv_stats *cnr)
{
uint32_t modulation, fec;
return DVB_QUAL_UNKNOWN;
}
- switch (parms->current_sys) {
+ switch (parms->p.current_sys) {
case SYS_DVBC_ANNEX_A:
case SYS_DVBC_ANNEX_C:
- dvb_fe_retrieve_parm(parms, DTV_MODULATION, &modulation);
+ dvb_fe_retrieve_parm(&parms->p, DTV_MODULATION, &modulation);
if (modulation == QAM_AUTO)
modulation = QAM_64; /* Assume worse case */
qual = cnr_arr_to_qual(modulation, FEC_NONE, cnr->svalue,
ARRAY_SIZE(dvb_c_cnr_2_qual));
break;
case SYS_DVBS:
- dvb_fe_retrieve_parm(parms, DTV_INNER_FEC, &fec);
+ dvb_fe_retrieve_parm(&parms->p, DTV_INNER_FEC, &fec);
qual = cnr_arr_to_qual(QPSK, fec, cnr->svalue,
dvb_s_cnr_2_qual,
ARRAY_SIZE(dvb_s_cnr_2_qual));
break;
case SYS_DVBS2:
- dvb_fe_retrieve_parm(parms, DTV_MODULATION, &modulation);
- dvb_fe_retrieve_parm(parms, DTV_INNER_FEC, &fec);
+ dvb_fe_retrieve_parm(&parms->p, DTV_MODULATION, &modulation);
+ dvb_fe_retrieve_parm(&parms->p, DTV_INNER_FEC, &fec);
qual = cnr_arr_to_qual(modulation, fec, cnr->svalue,
dvb_s2_cnr_2_qual,
ARRAY_SIZE(dvb_s_cnr_2_qual));
break;
case SYS_ISDBT:
- dvb_fe_retrieve_parm(parms, DTV_ISDBT_LAYERA_MODULATION, &modulation);
- dvb_fe_retrieve_parm(parms, DTV_ISDBT_LAYERA_FEC, &fec);
+ dvb_fe_retrieve_parm(&parms->p, DTV_ISDBT_LAYERA_MODULATION, &modulation);
+ dvb_fe_retrieve_parm(&parms->p, DTV_ISDBT_LAYERA_FEC, &fec);
if (modulation == QAM_AUTO)
modulation = QAM_64; /* Assume worse case */
qual = cnr_arr_to_qual(modulation, fec, cnr->svalue,
return qual;
};
-static enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
+static enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms_priv *parms,
unsigned layer)
{
float ber, per;
struct dtv_stats *cnr;
enum dvb_quality qual = DVB_QUAL_UNKNOWN;
- per = dvb_fe_retrieve_per(parms, layer);
+ per = dvb_fe_retrieve_per(&parms->p, layer);
if (per >= 0) {
if (per > 1e-6)
qual = DVB_QUAL_POOR;
return DVB_QUAL_GOOD;
}
- ber = dvb_fe_retrieve_per(parms, layer);
+ ber = dvb_fe_retrieve_per(&parms->p, layer);
if (ber >= 0) {
if (ber > 1e-3) /* FIXME: good enough???? */
qual = DVB_QUAL_OK; /* OK or good */
}
- cnr = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_CNR, layer);
+ cnr = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_CNR, layer);
if (cnr)
dvbv_fe_cnr_to_quality(parms, cnr);
return qual;
}
-static void dvb_fe_update_counters(struct dvb_v5_fe_parms *parms)
+static void dvb_fe_update_counters(struct dvb_v5_fe_parms_priv *parms)
{
struct dtv_stats *error, *count;
int i;
for (i = 0; i < MAX_DTV_STATS; i++) {
- count = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_POST_TOTAL_BIT_COUNT, i);
+ count = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_POST_TOTAL_BIT_COUNT, i);
if (count && count->scale != FE_SCALE_NOT_AVAILABLE) {
- error = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_POST_ERROR_BIT_COUNT, i);
+ error = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_POST_ERROR_BIT_COUNT, i);
if (!error || error->scale == FE_SCALE_NOT_AVAILABLE) {
parms->stats.has_post_ber[i] = 0;
} else if(count->uvalue != parms->stats.cur[i].post_bit_count) {
}
} else
parms->stats.has_post_ber[i] = 0;
- count = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_PRE_TOTAL_BIT_COUNT, i);
+ count = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_PRE_TOTAL_BIT_COUNT, i);
if (count && count->scale != FE_SCALE_NOT_AVAILABLE) {
- error = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_PRE_ERROR_BIT_COUNT, i);
+ error = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_PRE_ERROR_BIT_COUNT, i);
if (!error || error->scale == FE_SCALE_NOT_AVAILABLE) {
parms->stats.has_pre_ber[i] = 0;
} else if(count->uvalue != parms->stats.cur[i].pre_bit_count) {
}
} else
parms->stats.has_pre_ber[i] = 0;
- count = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_TOTAL_BLOCK_COUNT, i);
+ count = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_TOTAL_BLOCK_COUNT, i);
if (count && count->scale != FE_SCALE_NOT_AVAILABLE) {
- error = dvb_fe_retrieve_stats_layer(parms, DTV_STAT_ERROR_BLOCK_COUNT, i);
+ error = dvb_fe_retrieve_stats_layer(&parms->p, DTV_STAT_ERROR_BLOCK_COUNT, i);
if (!error || error->scale == FE_SCALE_NOT_AVAILABLE) {
parms->stats.has_per[i] = 0;
} else if (count->uvalue != parms->stats.cur[i].block_count) {
}
}
-int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms)
+int dvb_fe_get_stats(struct dvb_v5_fe_parms *p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
fe_status_t status = 0;
uint32_t ber= 0, ucb = 0;
uint16_t strength = 0, snr = 0;
if (status != parms->stats.prev_status) {
if ((status & FE_HAS_LOCK) &&
parms->stats.prev_status != status)
- dvb_fe_get_parms(parms);
+ dvb_fe_get_parms(&parms->p);
parms->stats.prev_status = status;
}
- if (parms->has_v5_stats) {
+ if (parms->p.has_v5_stats) {
struct dtv_properties props;
props.num = DTV_NUM_KERNEL_STATS;
dvbv3_fallback:
/* DVB v3 stats */
- parms->has_v5_stats = 0;
+ parms->p.has_v5_stats = 0;
if (ioctl(parms->fd, FE_READ_BER, &ber) == -1)
scale = FE_SCALE_NOT_AVAILABLE;
scale = FE_SCALE_COUNTER;
dvb_fe_store_stats(parms, DTV_STAT_ERROR_BLOCK_COUNT, scale, 0, snr);
- if (parms->verbose > 1) {
+ if (parms->p.verbose > 1) {
dvb_log("Status: ");
for (i = 0; i < ARRAY_SIZE(fe_status_name); i++) {
if (status & fe_status_name[i].idx)
}
-int dvb_fe_get_event(struct dvb_v5_fe_parms *parms)
+int dvb_fe_get_event(struct dvb_v5_fe_parms *p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
struct dvb_frontend_event event;
fe_status_t status;
int i;
- if (!parms->legacy_fe) {
- dvb_fe_get_parms(parms);
- return dvb_fe_get_stats(parms);
+ if (!parms->p.legacy_fe) {
+ dvb_fe_get_parms(&parms->p);
+ return dvb_fe_get_stats(&parms->p);
}
if (ioctl(parms->fd, FE_GET_EVENT, &event) == -1) {
return -1;
}
status = event.status;
- if (parms->verbose > 1) {
+ if (parms->p.verbose > 1) {
dvb_log("Status: ");
for (i = 0; i < ARRAY_SIZE(fe_status_name); i++) {
if (status & fe_status_name[i].idx)
}
dvb_fe_store_stats(parms, DTV_STATUS, FE_SCALE_RELATIVE, 0, status);
- dvb_fe_retrieve_parm(parms, DTV_FREQUENCY, &event.parameters.frequency);
- dvb_fe_retrieve_parm(parms, DTV_INVERSION, &event.parameters.inversion);
- switch (parms->current_sys) {
+ dvb_fe_retrieve_parm(&parms->p, DTV_FREQUENCY, &event.parameters.frequency);
+ dvb_fe_retrieve_parm(&parms->p, DTV_INVERSION, &event.parameters.inversion);
+ switch (parms->p.current_sys) {
case SYS_DVBS:
- dvb_fe_retrieve_parm(parms, DTV_SYMBOL_RATE, &event.parameters.u.qpsk.symbol_rate);
- dvb_fe_retrieve_parm(parms, DTV_INNER_FEC, &event.parameters.u.qpsk.fec_inner);
+ dvb_fe_retrieve_parm(&parms->p, DTV_SYMBOL_RATE, &event.parameters.u.qpsk.symbol_rate);
+ dvb_fe_retrieve_parm(&parms->p, DTV_INNER_FEC, &event.parameters.u.qpsk.fec_inner);
break;
case SYS_DVBC_ANNEX_AC:
- dvb_fe_retrieve_parm(parms, DTV_SYMBOL_RATE, &event.parameters.u.qam.symbol_rate);
- dvb_fe_retrieve_parm(parms, DTV_INNER_FEC, &event.parameters.u.qam.fec_inner);
- dvb_fe_retrieve_parm(parms, DTV_MODULATION, &event.parameters.u.qam.modulation);
+ dvb_fe_retrieve_parm(&parms->p, DTV_SYMBOL_RATE, &event.parameters.u.qam.symbol_rate);
+ dvb_fe_retrieve_parm(&parms->p, DTV_INNER_FEC, &event.parameters.u.qam.fec_inner);
+ dvb_fe_retrieve_parm(&parms->p, DTV_MODULATION, &event.parameters.u.qam.modulation);
break;
case SYS_ATSC:
case SYS_ATSCMH:
case SYS_DVBC_ANNEX_B:
- dvb_fe_retrieve_parm(parms, DTV_MODULATION, &event.parameters.u.vsb.modulation);
+ dvb_fe_retrieve_parm(&parms->p, DTV_MODULATION, &event.parameters.u.vsb.modulation);
break;
case SYS_DVBT:
- dvb_fe_retrieve_parm(parms, DTV_BANDWIDTH_HZ, &event.parameters.u.ofdm.bandwidth);
- dvb_fe_retrieve_parm(parms, DTV_CODE_RATE_HP, &event.parameters.u.ofdm.code_rate_HP);
- dvb_fe_retrieve_parm(parms, DTV_CODE_RATE_LP, &event.parameters.u.ofdm.code_rate_LP);
- dvb_fe_retrieve_parm(parms, DTV_MODULATION, &event.parameters.u.ofdm.constellation);
- dvb_fe_retrieve_parm(parms, DTV_TRANSMISSION_MODE, &event.parameters.u.ofdm.transmission_mode);
- dvb_fe_retrieve_parm(parms, DTV_GUARD_INTERVAL, &event.parameters.u.ofdm.guard_interval);
- dvb_fe_retrieve_parm(parms, DTV_HIERARCHY, &event.parameters.u.ofdm.hierarchy_information);
+ dvb_fe_retrieve_parm(&parms->p, DTV_BANDWIDTH_HZ, &event.parameters.u.ofdm.bandwidth);
+ dvb_fe_retrieve_parm(&parms->p, DTV_CODE_RATE_HP, &event.parameters.u.ofdm.code_rate_HP);
+ dvb_fe_retrieve_parm(&parms->p, DTV_CODE_RATE_LP, &event.parameters.u.ofdm.code_rate_LP);
+ dvb_fe_retrieve_parm(&parms->p, DTV_MODULATION, &event.parameters.u.ofdm.constellation);
+ dvb_fe_retrieve_parm(&parms->p, DTV_TRANSMISSION_MODE, &event.parameters.u.ofdm.transmission_mode);
+ dvb_fe_retrieve_parm(&parms->p, DTV_GUARD_INTERVAL, &event.parameters.u.ofdm.guard_interval);
+ dvb_fe_retrieve_parm(&parms->p, DTV_HIERARCHY, &event.parameters.u.ofdm.hierarchy_information);
break;
default:
return -EINVAL;
}
- return dvb_fe_get_stats(parms);
+ return dvb_fe_get_stats(&parms->p);
}
int dvb_fe_snprintf_eng(char *buf, int len, float val)
[DVB_QUAL_GOOD] = "Good",
};
-int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
+int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *p, uint32_t cmd,
char *display_name, int layer,
char **buf, int *len, int *show_layer_name)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
struct dtv_stats *stat = NULL;
enum dvb_quality qual = DVB_QUAL_UNKNOWN;
enum fecap_scale_params scale;
if (layer)
return 0;
- if (dvb_fe_retrieve_stats(parms, DTV_STATUS, &status)) {
+ if (dvb_fe_retrieve_stats(&parms->p, DTV_STATUS, &status)) {
dvb_logerr ("Error: no adapter status");
return -1;
}
scale = FE_SCALE_COUNTER;
break;
case DTV_BER:
- val = dvb_fe_retrieve_ber(parms, layer, &scale);
+ val = dvb_fe_retrieve_ber(&parms->p, layer, &scale);
if (scale == FE_SCALE_NOT_AVAILABLE)
return 0;
break;
case DTV_PER:
- val = dvb_fe_retrieve_per(parms, layer);
+ val = dvb_fe_retrieve_per(&parms->p, layer);
if (val < 0)
return 0;
scale = FE_SCALE_COUNTER;
return 0;
break;
default:
- stat = dvb_fe_retrieve_stats_layer(parms, cmd, layer);
+ stat = dvb_fe_retrieve_stats_layer(&parms->p, cmd, layer);
if (!stat || stat->scale == FE_SCALE_NOT_AVAILABLE)
return 0;
}
* version.
*/
-int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18)
+int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *p, int on, int v18)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
fe_sec_voltage_t v;
int rc;
if (!on) {
v = SEC_VOLTAGE_OFF;
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("DiSEqC VOLTAGE: OFF");
} else {
v = v18 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13;
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("DiSEqC VOLTAGE: %s", v18 ? "18" : "13");
}
rc = ioctl(parms->fd, FE_SET_VOLTAGE, v);
return rc;
}
-int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
+int dvb_fe_sec_tone(struct dvb_v5_fe_parms *p, fe_sec_tone_mode_t tone)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int rc;
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log( "DiSEqC TONE: %s", fe_tone_name[tone] );
rc = ioctl(parms->fd, FE_SET_TONE, tone);
if (rc == -1)
return rc;
}
-int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on)
+int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *p, int on)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
int rc;
if (on) on = 1;
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log( "DiSEqC HIGH LNB VOLTAGE: %s", on ? "ON" : "OFF" );
rc = ioctl(parms->fd, FE_ENABLE_HIGH_LNB_VOLTAGE, on);
if (rc == -1)
return rc;
}
-int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b)
+int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *p, int mini_b)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
fe_sec_mini_cmd_t mini;
int rc;
mini = mini_b ? SEC_MINI_B : SEC_MINI_A;
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log( "DiSEqC BURST: %s", mini_b ? "SEC_MINI_B" : "SEC_MINI_A" );
rc = ioctl(parms->fd, FE_DISEQC_SEND_BURST, mini);
if (rc == -1)
return rc;
}
-int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
+int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *p, const unsigned len,
const unsigned char *buf)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
struct dvb_diseqc_master_cmd msg;
int rc;
msg.msg_len = len;
memcpy(msg.msg, buf, len);
- if (parms->verbose) {
+ if (parms->p.verbose) {
int i;
char log[len * 3 + 20], *p = log;
return rc;
}
-int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
+int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *p, unsigned *len, char *buf,
int timeout)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)p;
struct dvb_diseqc_slave_reply reply;
int rc;
reply.timeout = timeout;
reply.msg_len = *len;
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("DiSEqC FE_DISEQC_RECV_SLAVE_REPLY");
rc = ioctl(parms->fd, FE_DISEQC_RECV_SLAVE_REPLY, reply);
#include <stdlib.h>
#include <sys/time.h>
+#include "dvb-fe-priv.h"
#include <libdvbv5/dvb-scan.h>
#include <libdvbv5/dvb-frontend.h>
#include <libdvbv5/descriptors.h>
#include <libdvbv5/crc32.h>
-#include <libdvbv5/dvb-fe.h>
#include <libdvbv5/dvb-file.h>
#include <libdvbv5/dvb-scan.h>
#include <libdvbv5/dvb-log.h>
int done;
};
-static int dvb_parse_section_alloc(struct dvb_v5_fe_parms *parms,
+static int dvb_parse_section_alloc(struct dvb_v5_fe_parms_priv *parms,
struct dvb_table_filter *sect)
{
struct dvb_table_filter_priv *priv;
}
}
-static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
+static int dvb_parse_section(struct dvb_v5_fe_parms_priv *parms,
struct dvb_table_filter *sect,
const uint8_t *buf, ssize_t buf_length)
{
memcpy(&h, buf, sizeof(struct dvb_table_header));
dvb_table_header_init(&h);
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("%s: received table 0x%02x, TS ID 0x%04x, section %d/%d",
__func__, h.table_id, h.id, h.section_id, h.last_section);
set_bit(h.section_id, priv->is_read_bits);
if (dvb_table_initializers[tid])
- dvb_table_initializers[tid](parms, buf, buf_length - DVB_CRC_SIZE,
- sect->table);
+ dvb_table_initializers[tid](&parms->p, buf,
+ buf_length - DVB_CRC_SIZE,
+ sect->table);
else
dvb_logerr("%s: no initializer for table %d",
__func__, tid);
return 1;
}
-int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
+int dvb_read_sections(struct dvb_v5_fe_parms *__p, int dmx_fd,
struct dvb_table_filter *sect,
unsigned timeout)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
int ret;
uint8_t *buf = NULL;
uint8_t mask = 0xff;
dvb_dmx_stop(dmx_fd);
return -1;
}
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("%s: waiting for table ID 0x%02x, program ID 0x%02x",
__func__, sect->tid, sect->pid);
ssize_t buf_length = 0;
do {
- available = poll(parms, dmx_fd, timeout);
+ available = poll(&parms->p, dmx_fd, timeout);
} while (available < 0 && errno == EOVERFLOW);
- if (parms->abort) {
+ if (parms->p.abort) {
ret = 0;
break;
}
free(dvb_scan_handler);
}
-struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
+struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *__p,
int dmx_fd,
uint32_t delivery_system,
unsigned other_nit,
unsigned timeout_multiply)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
int rc;
unsigned pat_pmt_time, sdt_time, nit_time, vct_time;
int atsc_filter = 0;
struct dvb_v5_descriptors *dvb_scan_handler;
- dvb_scan_handler = dvb_scan_alloc_handler_table(delivery_system, parms->verbose);
+ dvb_scan_handler = dvb_scan_alloc_handler_table(delivery_system, parms->p.verbose);
if (!dvb_scan_handler)
return NULL;
};
/* PAT table */
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
DVB_TABLE_PAT, DVB_TABLE_PAT_PID,
(void **)&dvb_scan_handler->pat,
pat_pmt_time * timeout_multiply);
- if (parms->abort)
+ if (parms->p.abort)
return dvb_scan_handler;
if (rc < 0) {
dvb_logerr("error while waiting for PAT table");
dvb_scan_free_handler_table(dvb_scan_handler);
return NULL;
}
- if (parms->verbose)
- dvb_table_pat_print(parms, dvb_scan_handler->pat);
+ if (parms->p.verbose)
+ dvb_table_pat_print(&parms->p, dvb_scan_handler->pat);
/* ATSC-specific VCT table */
if (atsc_filter) {
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
atsc_filter, ATSC_TABLE_VCT_PID,
(void **)&dvb_scan_handler->vct,
vct_time * timeout_multiply);
- if (parms->abort)
+ if (parms->p.abort)
return dvb_scan_handler;
if (rc < 0)
dvb_logerr("error while waiting for VCT table");
- else if (parms->verbose)
- atsc_table_vct_print(parms, dvb_scan_handler->vct);
+ else if (parms->p.verbose)
+ atsc_table_vct_print(&parms->p, dvb_scan_handler->vct);
}
/* PMT tables */
dvb_scan_handler->program[num_pmt].pat_pgm = program;
if (!program->service_id) {
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("Program #%d is network PID: 0x%04x",
num_pmt, program->pid);
num_pmt++;
continue;
}
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("Program #%d ID 0x%04x, service ID 0x%04x",
num_pmt, program->pid, program->service_id);
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
DVB_TABLE_PMT, program->pid,
(void **)&dvb_scan_handler->program[num_pmt].pmt,
pat_pmt_time * timeout_multiply);
- if (parms->abort) {
+ if (parms->p.abort) {
dvb_scan_handler->num_program = num_pmt + 1;
return dvb_scan_handler;
}
program->service_id);
dvb_scan_handler->program[num_pmt].pmt = NULL;
} else {
- if (parms->verbose)
- dvb_table_pmt_print(parms, dvb_scan_handler->program[num_pmt].pmt);
+ if (parms->p.verbose)
+ dvb_table_pmt_print(&parms->p,
+ dvb_scan_handler->program[num_pmt].pmt);
}
num_pmt++;
}
dvb_scan_handler->num_program = num_pmt;
/* NIT table */
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
DVB_TABLE_NIT, DVB_TABLE_NIT_PID,
(void **)&dvb_scan_handler->nit,
nit_time * timeout_multiply);
- if (parms->abort)
+ if (parms->p.abort)
return dvb_scan_handler;
if (rc < 0)
dvb_logerr("error while reading the NIT table");
- else if (parms->verbose)
- dvb_table_nit_print(parms, dvb_scan_handler->nit);
+ else if (parms->p.verbose)
+ dvb_table_nit_print(&parms->p, dvb_scan_handler->nit);
/* SDT table */
if (!dvb_scan_handler->vct || other_nit) {
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
DVB_TABLE_SDT, DVB_TABLE_SDT_PID,
(void **)&dvb_scan_handler->sdt,
sdt_time * timeout_multiply);
- if (parms->abort)
+ if (parms->p.abort)
return dvb_scan_handler;
if (rc < 0)
dvb_logerr("error while reading the SDT table");
- else if (parms->verbose)
- dvb_table_sdt_print(parms, dvb_scan_handler->sdt);
+ else if (parms->p.verbose)
+ dvb_table_sdt_print(&parms->p, dvb_scan_handler->sdt);
}
/* NIT/SDT other tables */
if (other_nit) {
- if (parms->verbose)
+ if (parms->p.verbose)
dvb_log("Parsing other NIT/SDT");
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
DVB_TABLE_NIT2, DVB_TABLE_NIT_PID,
(void **)&dvb_scan_handler->nit,
nit_time * timeout_multiply);
- if (parms->abort)
+ if (parms->p.abort)
return dvb_scan_handler;
if (rc < 0)
dvb_logerr("error while reading the NIT table");
- else if (parms->verbose)
- dvb_table_nit_print(parms, dvb_scan_handler->nit);
+ else if (parms->p.verbose)
+ dvb_table_nit_print(&parms->p, dvb_scan_handler->nit);
- rc = dvb_read_section(parms, dmx_fd,
+ rc = dvb_read_section(&parms->p, dmx_fd,
DVB_TABLE_SDT2, DVB_TABLE_SDT_PID,
(void **)&dvb_scan_handler->sdt,
sdt_time * timeout_multiply);
- if (parms->abort)
+ if (parms->p.abort)
return dvb_scan_handler;
if (rc < 0)
dvb_logerr("error while reading the SDT table");
- else if (parms->verbose)
- dvb_table_sdt_print(parms, dvb_scan_handler->sdt);
+ else if (parms->p.verbose)
+ dvb_table_sdt_print(&parms->p, dvb_scan_handler->sdt);
}
return dvb_scan_handler;
}
-struct dvb_v5_descriptors *dvb_scan_transponder(struct dvb_v5_fe_parms *parms,
+struct dvb_v5_descriptors *dvb_scan_transponder(struct dvb_v5_fe_parms *__p,
struct dvb_entry *entry,
int dmx_fd,
check_frontend_t *check_frontend,
unsigned other_nit,
unsigned timeout_multiply)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
struct dvb_v5_descriptors *dvb_scan_handler = NULL;
uint32_t freq, delsys = SYS_UNDEFINED;
int i, rc;
/* First of all, set the delivery system */
dvb_retrieve_entry_prop(entry, DTV_DELIVERY_SYSTEM, &delsys);
- dvb_set_compat_delivery_system(parms, delsys);
+ dvb_set_compat_delivery_system(&parms->p, delsys);
/* Copy data into parms */
for (i = 0; i < entry->n_props; i++) {
if (entry->props[i].cmd == DTV_DELIVERY_SYSTEM)
continue;
- dvb_fe_store_parm(parms, entry->props[i].cmd, data);
+ dvb_fe_store_parm(&parms->p, entry->props[i].cmd, data);
- if (parms->current_sys == SYS_ATSC &&
+ if (parms->p.current_sys == SYS_ATSC &&
entry->props[i].cmd == DTV_MODULATION) {
if (data != VSB_8 && data != VSB_16)
- dvb_fe_store_parm(parms,
+ dvb_fe_store_parm(&parms->p,
DTV_DELIVERY_SYSTEM,
SYS_DVBC_ANNEX_B);
}
}
- rc = dvb_fe_set_parms(parms);
+ rc = dvb_fe_set_parms(&parms->p);
if (rc < 0) {
dvb_perror("dvb_fe_set_parms failed");
return NULL;
}
/* As the DVB core emulates it, better to always use auto */
- dvb_fe_store_parm(parms, DTV_INVERSION, INVERSION_AUTO);
+ dvb_fe_store_parm(&parms->p, DTV_INVERSION, INVERSION_AUTO);
- dvb_fe_retrieve_parm(parms, DTV_FREQUENCY, &freq);
- if (parms->verbose)
- dvb_fe_prt_parms(parms);
+ dvb_fe_retrieve_parm(&parms->p, DTV_FREQUENCY, &freq);
+ if (parms->p.verbose)
+ dvb_fe_prt_parms(&parms->p);
- rc = check_frontend(args, parms);
+ rc = check_frontend(args, &parms->p);
if (rc < 0)
return NULL;
- dvb_scan_handler = dvb_get_ts_tables(parms, dmx_fd,
- parms->current_sys,
+ dvb_scan_handler = dvb_get_ts_tables(&parms->p, dmx_fd,
+ parms->p.current_sys,
other_nit,
timeout_multiply);
return dvb_scan_handler;
}
-int dvb_estimate_freq_shift(struct dvb_v5_fe_parms *parms)
+int dvb_estimate_freq_shift(struct dvb_v5_fe_parms *__p)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
uint32_t shift = 0, bw = 0, symbol_rate, ro;
int rolloff = 0;
int divisor = 100;
/* Need to handle only cable/satellite and ATSC standards */
- switch (parms->current_sys) {
+ switch (parms->p.current_sys) {
case SYS_DVBC_ANNEX_A:
rolloff = 115;
break;
case SYS_DSS:
case SYS_TURBO:
divisor = 100000;
- dvb_fe_retrieve_parm(parms, DTV_ROLLOFF, &ro);
+ dvb_fe_retrieve_parm(&parms->p, DTV_ROLLOFF, &ro);
switch (ro) {
case ROLLOFF_20:
rolloff = 120;
* guard interval there but it should be enough for the
* purposes of estimating a max frequency shift here.
*/
- dvb_fe_retrieve_parm(parms, DTV_SYMBOL_RATE, &symbol_rate);
+ dvb_fe_retrieve_parm(&parms->p, DTV_SYMBOL_RATE, &symbol_rate);
bw = (symbol_rate * rolloff) / divisor;
}
if (!bw)
- dvb_fe_retrieve_parm(parms, DTV_BANDWIDTH_HZ, &bw);
+ dvb_fe_retrieve_parm(&parms->p, DTV_BANDWIDTH_HZ, &bw);
/*
* If the max frequency shift between two frequencies is below
return 1;
}
-struct dvb_entry *dvb_scan_add_entry(struct dvb_v5_fe_parms *parms,
+struct dvb_entry *dvb_scan_add_entry(struct dvb_v5_fe_parms *__p,
struct dvb_entry *first_entry,
struct dvb_entry *entry,
uint32_t freq, uint32_t shift,
enum dvb_sat_polarization pol)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
struct dvb_entry *new_entry;
int i, n = 2;
}
-static void __dvb_add_update_transponders(struct dvb_v5_fe_parms *parms,
+static void __dvb_add_update_transponders(struct dvb_v5_fe_parms_priv *parms,
struct dvb_v5_descriptors *dvb_scan_handler,
struct dvb_entry *first_entry,
struct dvb_entry *entry,
uint32_t update)
{
struct update_transponders tr = {
- .parms = parms,
+ .parms = &parms->p,
.dvb_scan_handler = dvb_scan_handler,
.first_entry = first_entry,
.entry = entry,
if (!dvb_scan_handler->nit)
return;
- tr.shift = dvb_estimate_freq_shift(parms);
+ tr.shift = dvb_estimate_freq_shift(&parms->p);
- switch (parms->current_sys) {
+ switch (parms->p.current_sys) {
case SYS_DVBC_ANNEX_A:
case SYS_DVBC_ANNEX_C:
dvb_table_nit_descriptor_handler(
- parms, dvb_scan_handler->nit,
+ &parms->p, dvb_scan_handler->nit,
cable_delivery_system_descriptor,
NULL, add_update_nit_dvbc, &tr);
return;
case SYS_ISDBT:
dvb_table_nit_descriptor_handler(
- parms, dvb_scan_handler->nit,
+ &parms->p, dvb_scan_handler->nit,
partial_reception_descriptor,
NULL, add_update_nit_1seg, &tr);
- dvb_table_nit_descriptor_handler(parms, dvb_scan_handler->nit,
+ dvb_table_nit_descriptor_handler(&parms->p,
+ dvb_scan_handler->nit,
ISDBT_delivery_system_descriptor,
NULL, add_update_nit_isdbt, &tr);
return;
case SYS_DVBT:
case SYS_DVBT2:
dvb_table_nit_descriptor_handler(
- parms, dvb_scan_handler->nit,
+ &parms->p, dvb_scan_handler->nit,
extension_descriptor,
NULL, add_update_nit_dvbt2, &tr);
dvb_table_nit_descriptor_handler(
- parms, dvb_scan_handler->nit,
+ &parms->p, dvb_scan_handler->nit,
terrestrial_delivery_system_descriptor,
NULL, add_update_nit_dvbt, &tr);
return;
case SYS_DVBS:
case SYS_DVBS2:
dvb_table_nit_descriptor_handler(
- parms, dvb_scan_handler->nit,
+ &parms->p, dvb_scan_handler->nit,
satellite_delivery_system_descriptor,
NULL, add_update_nit_dvbs, &tr);
return;
}
}
-void dvb_add_scaned_transponders(struct dvb_v5_fe_parms *parms,
+void dvb_add_scaned_transponders(struct dvb_v5_fe_parms *__p,
struct dvb_v5_descriptors *dvb_scan_handler,
struct dvb_entry *first_entry,
struct dvb_entry *entry)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
+
return __dvb_add_update_transponders(parms, dvb_scan_handler,
first_entry, entry, 0);
}
-void dvb_update_transponders(struct dvb_v5_fe_parms *parms,
+void dvb_update_transponders(struct dvb_v5_fe_parms *__p,
struct dvb_v5_descriptors *dvb_scan_handler,
struct dvb_entry *first_entry,
struct dvb_entry *entry)
{
+ struct dvb_v5_fe_parms_priv *parms = (void *)__p;
+
return __dvb_add_update_transponders(parms, dvb_scan_handler,
first_entry, entry, 1);
}