libdvbv5: move internal parameters to a separate structure
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Sat, 30 Aug 2014 16:41:32 +0000 (13:41 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sat, 30 Aug 2014 20:23:16 +0000 (17:23 -0300)
We don't want that struct dvb_v5_fe_parms size to change on
future versions of the API. Due to that, move all parameters
that shouldn't be visible to userspace into a private structure,
called struct dvb_v5_fe_parms_priv.

With this change, the dvb-fe will now allocate memory for the
private struct, but only the non-priv fields are visible at
the external structure.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/include/libdvbv5/dvb-fe.h
lib/include/libdvbv5/dvb-log.h
lib/libdvbv5/dvb-fe.c
lib/libdvbv5/dvb-file.c
lib/libdvbv5/dvb-sat.c
lib/libdvbv5/dvb-scan.c

index 18807b7..87787b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 - Mauro Carvalho Chehab
+ * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 #define DTV_SNR                                DTV_STAT_CNR
 #define DTV_UNCORRECTED_BLOCKS         DTV_STAT_ERROR_BLOCK_COUNT
 
-enum dvbv3_emulation_type {
-       DVBV3_UNKNOWN = -1,
-       DVBV3_QPSK,
-       DVBV3_QAM,
-       DVBV3_OFDM,
-       DVBV3_ATSC,
-};
-
-struct dvb_v5_counters {
-       uint64_t                        pre_bit_count;
-       uint64_t                        pre_bit_error;
-       uint64_t                        post_bit_count;
-       uint64_t                        post_bit_error;
-       uint64_t                        block_count;
-       uint64_t                        block_error;
-};
-
-struct dvb_v5_stats {
-       struct dtv_property             prop[DTV_NUM_STATS_PROPS];
-
-       struct dvb_v5_counters          prev[MAX_DTV_STATS];
-       struct dvb_v5_counters          cur[MAX_DTV_STATS];
-
-       int                             has_post_ber[MAX_DTV_STATS];
-       int                             has_pre_ber[MAX_DTV_STATS];
-       int                             has_per[MAX_DTV_STATS];
-
-       fe_status_t prev_status;
-
-};
 
 struct dvb_v5_fe_parms {
-       int                             fd;
-       char                            *fname;
-       unsigned                        verbose;
+       /* Information visible to the client - don't override those values */
        struct dvb_frontend_info        info;
        uint32_t                        version;
        int                             has_v5_stats;
        fe_delivery_system_t            current_sys;
        int                             num_systems;
        fe_delivery_system_t            systems[MAX_DELIVERY_SYSTEMS];
-       int                             n_props;
-       struct dtv_property             dvb_prop[DTV_MAX_COMMAND];
        int                             legacy_fe;
-       struct dvb_v5_stats             stats;
-       int                             lna;
 
-       /* Charsets to be used by the conversion utilities */
-       char                            *default_charset;
-       char                            *output_charset;
+       /* The values below are specified by the library client */
+
+       /* Flags from the client to the library */
+       int                             abort;
 
-       /* Satellite specific stuff, specified by the library client */
+       /* Linear Amplifier settings */
+       int                             lna;
+
+       /* Satellite settings */
        const struct dvb_sat_lnb        *lnb;
        int                             sat_number;
        unsigned                        freq_bpf;
-
-       /* Satellite specific stuff, used internally */
-       int                             high_band;
        unsigned                        diseqc_wait;
-       unsigned                        freq_offset;
 
-       int                             abort;
+       /* Function to write DVB logs */
+       unsigned                        verbose;
        dvb_logfunc                     logfunc;
+
+       /* Charsets to be used by the conversion utilities */
+       char                            *default_charset;
+       char                            *output_charset;
 };
 
 
index 755167a..cca350e 100644 (file)
@@ -26,6 +26,8 @@
 
 typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
 
+#ifndef __DVB_FE_PRIV_H
+
 #define dvb_log(fmt, arg...) do {\
        parms->logfunc(LOG_INFO, fmt, ##arg); \
 } while (0)
@@ -42,11 +44,34 @@ typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( fo
        parms->logfunc(LOG_NOTICE, fmt, ##arg); \
 } while (0)
 
-
 #define dvb_perror(msg) do {\
        parms->logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
 } while (0)
 
+#else
+
+#define dvb_log(fmt, arg...) do {\
+       parms->p.logfunc(LOG_INFO, fmt, ##arg); \
+} while (0)
+#define dvb_logerr(fmt, arg...) do {\
+       parms->p.logfunc(LOG_ERR, fmt, ##arg); \
+} while (0)
+#define dvb_logdbg(fmt, arg...) do {\
+       parms->p.logfunc(LOG_DEBUG, fmt, ##arg); \
+} while (0)
+#define dvb_logwarn(fmt, arg...) do {\
+       parms->p.logfunc(LOG_WARNING, fmt, ##arg); \
+} while (0)
+#define dvb_loginfo(fmt, arg...) do {\
+       parms->p.logfunc(LOG_NOTICE, fmt, ##arg); \
+} while (0)
+
+#define dvb_perror(msg) do {\
+       parms->p.logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
+} while (0)
+
+#endif
+
 void dvb_default_log(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
 
 #endif
index c1f0264..8fb3125 100644 (file)
  */
 #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);
@@ -35,11 +35,15 @@ static void dvb_v5_free(struct dvb_v5_fe_parms *parms)
        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,
@@ -55,7 +59,7 @@ struct dvb_v5_fe_parms *dvb_fe_open2(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) {
@@ -81,16 +85,16 @@ struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend, unsigned verbose
                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);
@@ -99,10 +103,10 @@ struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend, unsigned verbose
        }
 
        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);
@@ -120,57 +124,57 @@ struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend, unsigned verbose
                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);
@@ -189,11 +193,11 @@ struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend, unsigned verbose
                        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);
@@ -204,27 +208,27 @@ struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend, unsigned verbose
 
        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
@@ -246,7 +250,7 @@ struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend, unsigned verbose
        parms->stats.prop[11].cmd = DTV_QUALITY;
        parms->stats.prop[12].cmd = DTV_PRE_BER;
 
-       return parms;
+       return &parms->p;
 }
 
 
@@ -265,8 +269,10 @@ int dvb_fe_is_satellite(uint32_t delivery_system)
 }
 
 
-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;
 
@@ -274,8 +280,8 @@ void dvb_fe_close(struct dvb_v5_fe_parms *parms)
                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);
 
@@ -309,21 +315,21 @@ int dvb_add_parms_for_sys(struct dtv_property *dvb_prop,
        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;
@@ -342,7 +348,7 @@ int dvb_set_sys(struct dvb_v5_fe_parms *parms,
        if (rc < 0)
                return EINVAL;
 
-       parms->current_sys = sys;
+       parms->p.current_sys = sys;
        parms->n_props = rc;
 
        return 0;
@@ -384,17 +390,18 @@ static int is_dvbv3_delsys(uint32_t delsys)
        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;
                }
        }
@@ -409,10 +416,10 @@ int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
         * 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)
@@ -420,29 +427,29 @@ int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
 
        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;
 }
@@ -465,8 +472,9 @@ const char *const *dvb_attr_names(int cmd)
        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++) {
@@ -492,9 +500,10 @@ void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms)
        }
 };
 
-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)
@@ -508,9 +517,10 @@ int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
        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)
@@ -533,15 +543,16 @@ static int dvb_copy_fe_props(const struct dtv_property *from, int n, struct dtv_
        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;
 
@@ -550,7 +561,7 @@ int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
                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 */
@@ -562,7 +573,7 @@ int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
 
        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;
@@ -570,12 +581,12 @@ int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
 
                /* 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;
        }
@@ -585,34 +596,34 @@ int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
                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;
@@ -621,37 +632,40 @@ int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
        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;
@@ -659,67 +673,68 @@ int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms)
        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;
@@ -734,7 +749,7 @@ static struct dtv_stats *dvb_fe_store_stats(struct dvb_v5_fe_parms *parms,
        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;
 
@@ -750,7 +765,7 @@ static float calculate_postBER(struct dvb_v5_fe_parms *parms, unsigned layer)
        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;
 
@@ -766,7 +781,7 @@ static float calculate_preBER(struct dvb_v5_fe_parms *parms, unsigned layer)
        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;
@@ -785,12 +800,13 @@ static struct dtv_stats *dvb_fe_retrieve_v5_BER(struct dvb_v5_fe_parms *parms,
        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++) {
@@ -805,41 +821,43 @@ struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
        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;
@@ -853,7 +871,7 @@ float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
                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;
@@ -861,8 +879,9 @@ float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
        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]) {
@@ -996,7 +1015,7 @@ static struct cnr_to_qual_s dvb_t_cnr_2_qual[] = {
        { 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;
@@ -1017,10 +1036,10 @@ static enum dvb_quality dvbv_fe_cnr_to_quality(struct dvb_v5_fe_parms *parms,
                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,
@@ -1028,21 +1047,21 @@ static enum dvb_quality dvbv_fe_cnr_to_quality(struct dvb_v5_fe_parms *parms,
                                       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,
@@ -1066,14 +1085,14 @@ static enum dvb_quality dvbv_fe_cnr_to_quality(struct dvb_v5_fe_parms *parms,
        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;
@@ -1083,7 +1102,7 @@ static enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
                        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???? */
@@ -1094,22 +1113,22 @@ static enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
                        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) {
@@ -1123,9 +1142,9 @@ static void dvb_fe_update_counters(struct dvb_v5_fe_parms *parms)
                        }
                } 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) {
@@ -1139,9 +1158,9 @@ static void dvb_fe_update_counters(struct dvb_v5_fe_parms *parms)
                        }
                } 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) {
@@ -1158,8 +1177,9 @@ static void dvb_fe_update_counters(struct dvb_v5_fe_parms *parms)
        }
 }
 
-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;
@@ -1176,11 +1196,11 @@ int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms)
        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;
@@ -1207,7 +1227,7 @@ int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms)
 
 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;
@@ -1239,7 +1259,7 @@ dvbv3_fallback:
                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)
@@ -1252,15 +1272,16 @@ dvbv3_fallback:
 }
 
 
-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) {
@@ -1268,7 +1289,7 @@ int dvb_fe_get_event(struct dvb_v5_fe_parms *parms)
                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)
@@ -1277,37 +1298,37 @@ int dvb_fe_get_event(struct dvb_v5_fe_parms *parms)
        }
        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)
@@ -1376,10 +1397,11 @@ static char *qual_name[] = {
        [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;
@@ -1394,7 +1416,7 @@ int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
                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;
                }
@@ -1433,12 +1455,12 @@ int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
                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;
@@ -1449,7 +1471,7 @@ int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
                        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;
        }
@@ -1522,18 +1544,19 @@ int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
  * 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);
@@ -1542,10 +1565,11 @@ int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18)
        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)
@@ -1553,12 +1577,13 @@ int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
        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)
@@ -1566,14 +1591,15 @@ int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on)
        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)
@@ -1581,9 +1607,10 @@ int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b)
        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;
 
@@ -1593,7 +1620,7 @@ int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
        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;
 
@@ -1609,9 +1636,10 @@ int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
        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;
 
@@ -1621,7 +1649,7 @@ int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
        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);
index a1f8437..6d978e6 100644 (file)
@@ -24,6 +24,7 @@
 #include <strings.h> /* strcasecmp */
 #include <unistd.h>
 
+#include "dvb-fe-priv.h"
 #include <libdvbv5/dvb-file.h>
 #include <libdvbv5/dvb-v5-std.h>
 #include <libdvbv5/dvb-scan.h>
@@ -810,7 +811,8 @@ int dvb_write_file(const char *fname, struct dvb_file *dvb_file)
        return 0;
 };
 
-static char *dvb_vchannel(struct dvb_v5_fe_parms *parms, struct dvb_table_nit *nit, uint16_t service_id)
+static char *dvb_vchannel(struct dvb_v5_fe_parms_priv *parms,
+                         struct dvb_table_nit *nit, uint16_t service_id)
 {
        int i;
        char *buf;
@@ -818,7 +820,7 @@ static char *dvb_vchannel(struct dvb_v5_fe_parms *parms, struct dvb_table_nit *n
        if (!nit)
                return NULL;
 
-for( struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) \
+       for( struct dvb_desc_logical_channel *desc = (struct dvb_desc_logical_channel *) nit->descriptor; desc; desc = (struct dvb_desc_logical_channel *) desc->next ) \
                if(desc->type == logical_channel_number_descriptor) {
 /* FIXME:  dvb_desc_find(struct dvb_desc_logical_channel, desc, nit, logical_channel_number_descriptor) ? */
                struct dvb_desc_logical_channel *d = (void *)desc;
@@ -947,7 +949,7 @@ static void get_pmt_descriptors(struct dvb_entry *entry,
              sizeof(*entry->other_el_pid), sort_other_el_pid);
 }
 
-static int get_program_and_store(struct dvb_v5_fe_parms *parms,
+static int get_program_and_store(struct dvb_v5_fe_parms_priv *parms,
                                 struct dvb_file *dvb_file,
                                 struct dvb_v5_descriptors *dvb_scan_handler,
                                 const uint16_t service_id,
@@ -998,11 +1000,11 @@ static int get_program_and_store(struct dvb_v5_fe_parms *parms,
        /* Initialize data */
        entry->service_id = service_id;
        entry->vchannel = vchannel;
-       entry->sat_number = parms->sat_number;
-       entry->freq_bpf = parms->freq_bpf;
-       entry->diseqc_wait = parms->diseqc_wait;
-       if (parms->lnb)
-               entry->lnb = strdup(parms->lnb->alias);
+       entry->sat_number = parms->p.sat_number;
+       entry->freq_bpf = parms->p.freq_bpf;
+       entry->diseqc_wait = parms->p.diseqc_wait;
+       if (parms->p.lnb)
+               entry->lnb = strdup(parms->p.lnb->alias);
 
        /* Get PIDs for each elementary inside the service ID */
        get_pmt_descriptors(entry, dvb_scan_handler->program[i].pmt);
@@ -1011,7 +1013,7 @@ static int get_program_and_store(struct dvb_v5_fe_parms *parms,
        if (get_detected) {
                int rc;
                do {
-                       rc = dvb_fe_get_parms(parms);
+                       rc = dvb_fe_get_parms(&parms->p);
                        if (rc == EAGAIN)
                                usleep(100000);
                } while (rc == EAGAIN);
@@ -1031,15 +1033,15 @@ static int get_program_and_store(struct dvb_v5_fe_parms *parms,
                r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id);
                if (r < 0)
                        dvb_perror("asprintf");
-               if (parms->verbose)
+               if (parms->p.verbose)
                        dvb_log("Storing as: '%s'", channel);
        }
        entry->channel = channel;
 
        if (get_nit)
-               dvb_update_transponders(parms, dvb_scan_handler,
-                                           dvb_file->first_entry,
-                                           entry);
+               dvb_update_transponders(&parms->p, dvb_scan_handler,
+                                       dvb_file->first_entry,
+                                       entry);
 
        return 0;
 }
@@ -1063,10 +1065,11 @@ static char *sdt_services[256] = {
 };
 
 int dvb_store_channel(struct dvb_file **dvb_file,
-                     struct dvb_v5_fe_parms *parms,
+                     struct dvb_v5_fe_parms *__p,
                      struct dvb_v5_descriptors *dvb_scan_handler,
                      int get_detected, int get_nit)
 {
+       struct dvb_v5_fe_parms_priv *parms = (void *)__p;
        int rc;
 
        if (!*dvb_file) {
@@ -1092,7 +1095,7 @@ int dvb_store_channel(struct dvb_file **dvb_file,
                        if (r < 0)
                                dvb_perror("asprintf");
 
-                       if (parms->verbose)
+                       if (parms->p.verbose)
                                dvb_log("Virtual channel %s, name = %s",
                                        vchannel, channel);
 
@@ -1154,7 +1157,7 @@ int dvb_store_channel(struct dvb_file **dvb_file,
                                dvb_perror("asprintf");
                }
 
-               if (parms->verbose)
+               if (parms->p.verbose)
                        dvb_log("Storing as channel %s", channel);
                vchannel = dvb_vchannel(parms, dvb_scan_handler->nit, service->service_id);
 
index d0a6076..7eae267 100644 (file)
@@ -23,7 +23,7 @@
 #include <unistd.h>
 #include <strings.h> /* strcasecmp */
 
-#include <libdvbv5/dvb-fe.h>
+#include "dvb-fe-priv.h"
 #include <libdvbv5/dvb-v5-std.h>
 
 static const struct dvb_sat_lnb lnb[] = {
@@ -227,7 +227,8 @@ static void dvbsat_diseqc_prep_frame_addr(struct diseqc_cmd *cmd,
 //struct dvb_v5_fe_parms *parms; // legacy code, used for parms->fd, FIXME anyway
 
 /* Inputs are numbered from 1 to 16, according with the spec */
-static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms *parms, struct diseqc_cmd *cmd,
+static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms_priv *parms,
+                                            struct diseqc_cmd *cmd,
                                             int high_band,
                                             int pol_v,
                                             int sat_number)
@@ -246,10 +247,11 @@ static int dvbsat_diseqc_write_to_port_group(struct dvb_v5_fe_parms *parms, stru
        /* Instead of using position/option, use a number from 0 to 3 */
        cmd->data0 |= (sat_number % 0x3) << 2;
 
-       return dvb_fe_diseqc_cmd(parms, cmd->len, cmd->msg);
+       return dvb_fe_diseqc_cmd(&parms->p, cmd->len, cmd->msg);
 }
 
-static int dvbsat_scr_odu_channel_change(struct dvb_v5_fe_parms *parms, struct diseqc_cmd *cmd,
+static int dvbsat_scr_odu_channel_change(struct dvb_v5_fe_parms_priv *parms,
+                                        struct diseqc_cmd *cmd,
                                         int high_band,
                                         int pol_v,
                                         int sat_number,
@@ -277,17 +279,18 @@ static int dvbsat_scr_odu_channel_change(struct dvb_v5_fe_parms *parms, struct d
        cmd->data0 |= pol_v ? 8 : 0;
        cmd->data0 |= pos_b ? 16 : 0;
 
-       return dvb_fe_diseqc_cmd(parms, cmd->len, cmd->msg);
+       return dvb_fe_diseqc_cmd(&parms->p, cmd->len, cmd->msg);
 }
 
-static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
+static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms_priv *parms,
+                                  uint16_t t)
 {
        int rc;
        enum dvb_sat_polarization pol;
-       dvb_fe_retrieve_parm(parms, DTV_POLARIZATION, &pol);
+       dvb_fe_retrieve_parm(&parms->p, DTV_POLARIZATION, &pol);
        int pol_v = (pol == POLARIZATION_V) || (pol == POLARIZATION_R);
        int high_band = parms->high_band;
-       int sat_number = parms->sat_number;
+       int sat_number = parms->p.sat_number;
        int vol_high = 0;
        int tone_on = 0;
        int mini_b = 0;
@@ -303,19 +306,19 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
                high_band = 1;
        } else {
                /* Adjust voltage/tone accordingly */
-               if (parms->sat_number < 2) {
+               if (parms->p.sat_number < 2) {
                        vol_high = pol_v ? 0 : 1;
                        tone_on = high_band;
-                       mini_b = parms->sat_number & 1;
+                       mini_b = parms->p.sat_number & 1;
                }
        }
 
-       rc = dvb_fe_sec_voltage(parms, 1, vol_high);
+       rc = dvb_fe_sec_voltage(&parms->p, 1, vol_high);
        if (rc)
                return rc;
 
-       if (parms->sat_number > 0) {
-               rc = dvb_fe_sec_tone(parms, SEC_TONE_OFF);
+       if (parms->p.sat_number > 0) {
+               rc = dvb_fe_sec_tone(&parms->p, SEC_TONE_OFF);
                if (rc)
                        return rc;
 
@@ -332,15 +335,15 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
                        dvb_logerr("sending diseq failed");
                        return rc;
                }
-               usleep((15 + parms->diseqc_wait) * 1000);
+               usleep((15 + parms->p.diseqc_wait) * 1000);
 
-               rc = dvb_fe_diseqc_burst(parms, mini_b);
+               rc = dvb_fe_diseqc_burst(&parms->p, mini_b);
                if (rc)
                        return rc;
                usleep(15 * 1000);
        }
 
-       rc = dvb_fe_sec_tone(parms, tone_on ? SEC_TONE_ON : SEC_TONE_OFF);
+       rc = dvb_fe_sec_tone(&parms->p, tone_on ? SEC_TONE_ON : SEC_TONE_OFF);
 
        return rc;
 }
@@ -350,16 +353,17 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
  */
 
 
-int dvb_sat_set_parms(struct dvb_v5_fe_parms *parms)
+int dvb_sat_set_parms(struct dvb_v5_fe_parms *p)
 {
+       struct dvb_v5_fe_parms_priv *parms = (void *)p;
        const struct dvb_sat_lnb *lnb = parms->lnb;
        enum dvb_sat_polarization pol;
-       dvb_fe_retrieve_parm(parms, DTV_POLARIZATION, &pol);
+       dvb_fe_retrieve_parm(&parms->p, DTV_POLARIZATION, &pol);
        uint32_t freq;
        uint16_t t = 0;
        int rc;
 
-       dvb_fe_retrieve_parm(parms, DTV_FREQUENCY, &freq);
+       dvb_fe_retrieve_parm(&parms->p, DTV_FREQUENCY, &freq);
 
        if (!lnb) {
                dvb_logerr("Need a LNBf to work");
@@ -391,8 +395,8 @@ int dvb_sat_set_parms(struct dvb_v5_fe_parms *parms)
                parms->freq_offset = lnb->lowfreq * 1000;
 
        /* For SCR/Unicable setups */
-       if (parms->freq_bpf) {
-               t = (((freq / 1000) + parms->freq_bpf + 2) / 4) - 350;
+       if (parms->p.freq_bpf) {
+               t = (((freq / 1000) + parms->p.freq_bpf + 2) / 4) - 350;
                parms->freq_offset += ((t + 350) * 4) * 1000;
        }
 
@@ -400,7 +404,7 @@ ret:
        rc = dvbsat_diseqc_set_input(parms, t);
 
        freq = abs(freq - parms->freq_offset);
-       dvb_fe_store_parm(parms, DTV_FREQUENCY, freq);
+       dvb_fe_store_parm(&parms->p, DTV_FREQUENCY, freq);
 
        return rc;
 }
index e11664e..ad88d32 100644 (file)
 #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>
@@ -133,7 +133,7 @@ struct dvb_table_filter_priv {
        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;
@@ -165,7 +165,7 @@ void dvb_table_filter_free(struct dvb_table_filter *sect)
        }
 }
 
-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)
 {
@@ -176,7 +176,7 @@ static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
        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);
 
@@ -220,8 +220,9 @@ static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
                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);
@@ -237,10 +238,11 @@ static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
        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;
@@ -255,7 +257,7 @@ int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
                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);
 
@@ -274,10 +276,10 @@ int dvb_read_sections(struct dvb_v5_fe_parms *parms, int dmx_fd,
                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;
                }
@@ -371,12 +373,13 @@ void dvb_scan_free_handler_table(struct dvb_v5_descriptors *dvb_scan_handler)
        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;
@@ -384,7 +387,7 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
 
        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;
 
@@ -435,32 +438,32 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
        };
 
        /* 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 */
@@ -471,20 +474,20 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
                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;
                }
@@ -493,70 +496,71 @@ struct dvb_v5_descriptors *dvb_get_ts_tables(struct dvb_v5_fe_parms *parms,
                                   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,
@@ -564,13 +568,14 @@ struct dvb_v5_descriptors *dvb_scan_transponder(struct dvb_v5_fe_parms *parms,
                                                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++) {
@@ -580,50 +585,51 @@ struct dvb_v5_descriptors *dvb_scan_transponder(struct dvb_v5_fe_parms *parms,
                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;
@@ -639,7 +645,7 @@ int dvb_estimate_freq_shift(struct dvb_v5_fe_parms *parms)
        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;
@@ -667,11 +673,11 @@ int dvb_estimate_freq_shift(struct dvb_v5_fe_parms *parms)
                 * 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
@@ -705,12 +711,13 @@ int dvb_new_freq_is_needed(struct dvb_entry *entry, struct dvb_entry *last_entry
        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;
 
@@ -983,14 +990,14 @@ static void add_update_nit_dvbs(struct dvb_table_nit *nit,
 }
 
 
-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,
@@ -1001,41 +1008,42 @@ static void __dvb_add_update_transponders(struct dvb_v5_fe_parms *parms,
        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;
@@ -1045,20 +1053,24 @@ static void __dvb_add_update_transponders(struct dvb_v5_fe_parms *parms,
        }
 }
 
-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);
 }