dvb-fe.h
Go to the documentation of this file.
/*
* 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 Lesser General Public License as published by
* the Free Software Foundation version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _DVB_FE_H
#define _DVB_FE_H
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include "dvb-frontend.h"
#include "dvb-sat.h"
#include "dvb-log.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#define MAX_DELIVERY_SYSTEMS 20
#ifndef _DOXYGEN
/*
* There are a few aliases for other properties. Those are needed just
* to avoid breaking apps that depend on the library but shoudn't be used
* anymore on newer apps.
*/
#define DTV_MAX_STATS DTV_NUM_STATS_PROPS
#define DTV_SIGNAL_STRENGTH DTV_STAT_SIGNAL_STRENGTH
#define DTV_SNR DTV_STAT_CNR
#define DTV_UNCORRECTED_BLOCKS DTV_STAT_ERROR_BLOCK_COUNT
#endif
struct dvb_v5_fe_parms {
/* 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 legacy_fe;
/* The values below are specified by the library client */
/* Flags from the client to the library */
int abort;
/* Linear Amplifier settings */
int lna;
/* Satellite settings */
const struct dvb_sat_lnb *lnb;
int sat_number;
unsigned freq_bpf;
unsigned diseqc_wait;
/* Function to write DVB logs */
unsigned verbose;
dvb_logfunc logfunc;
/* Charsets to be used by the conversion utilities */
char *default_charset;
char *output_charset;
};
#ifdef __cplusplus
extern "C" {
#endif
struct dvb_v5_fe_parms *dvb_fe_dummy(void);
struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
unsigned verbose,
unsigned use_legacy_call,
dvb_logfunc logfunc,
int flags);
struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
unsigned verbose,
unsigned use_legacy_call);
struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
unsigned verbose, unsigned use_legacy_call,
dvb_logfunc logfunc);
void dvb_fe_close(struct dvb_v5_fe_parms *parms);
const char *dvb_cmd_name(int cmd);
const char *const *dvb_attr_names(int cmd);
/* Get/set delivery system parameters */
int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
unsigned cmd, uint32_t *value);
int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
unsigned cmd, uint32_t value);
int dvb_set_sys(struct dvb_v5_fe_parms *parms,
fe_delivery_system_t sys);
int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
fe_delivery_system_t sys);
int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
uint32_t desired_system);
void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
/*
* statistics functions
*/
struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
unsigned cmd, unsigned layer);
int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
unsigned cmd, uint32_t *value);
int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
enum fecap_scale_params *scale);
float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
unsigned layer);
int dvb_fe_snprintf_eng(char *buf, int len, float val);
int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
char *display_name, int layer,
char **buf, int *len, int *show_layer_name);
int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
/*
* Other functions, associated to SEC/LNB/DISEqC
*
* The functions below are just wrappers for the Kernel calls, in order to
* manually control satellite systems.
*
* Instead of using most them, the best is to set the LNBf parameters, and let
* the libdvbv5 to automatically handle the calls.
*
* NOTE: It currently lacks support for two ioctl's:
* FE_DISEQC_RESET_OVERLOAD used only on av7110.
* Spec says:
* If the bus has been automatically powered off due to power overload,
* this ioctl call restores the power to the bus. The call requires read/write
* access to the device. This call has no effect if the device is manually
* powered off. Not all DVB adapters support this ioctl.
*
* FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
* Spec says:
* WARNING: This is a very obscure legacy command, used only at stv0299
* driver. Should not be used on newer drivers.
* It provides a non-standard method for selecting Diseqc voltage on the
* frontend, for Dish Network legacy switches.
* As support for this ioctl were added in 2004, this means that such dishes
* were already legacy in 2004.
*
* So, it doesn't make much sense on implementing support for them.
*/
int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
const unsigned char *buf);
int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
int timeout);
int dvb_fe_is_satellite(uint32_t delivery_system);
int dvb_fe_set_default_country(struct dvb_v5_fe_parms *parms,
const char *country);
#ifdef __cplusplus
}
#endif
/*
* Arrays from dvb-v5.h
*
* Those arrays can be used to translate from a DVB property into a name.
*
* No need to directly access them from userspace, as dvb_attr_names()
* already handles them into a more standard way.
*/
#ifndef _DOXYGEN
extern const unsigned fe_bandwidth_name[8];
extern const char *dvb_v5_name[72];
extern const void *dvb_v5_attr_names[];
extern const char *delivery_system_name[21];
extern const char *fe_code_rate_name[34];
extern const char *fe_modulation_name[22];
extern const char *fe_transmission_mode_name[10];
extern const unsigned fe_bandwidth_name[8];
extern const char *fe_guard_interval_name[13];
extern const char *fe_hierarchy_name[6];
extern const char *fe_voltage_name[4];
extern const char *fe_tone_name[3];
extern const char *fe_inversion_name[4];
extern const char *fe_pilot_name[4];
extern const char *fe_rolloff_name[8];
#endif
#endif
dvb-log.h
Provides interfaces to handle libdvbv5 log messages.
dvb-sat.h
Provides interfaces to deal with DVB Satellite systems.
dvb_logfunc
void(* dvb_logfunc)(int level, const char *fmt,...)
typedef used by dvb_fe_open2 for the log function
Definition dvb-log.h:44
dvb_fe_set_default_country
int dvb_fe_set_default_country(struct dvb_v5_fe_parms *parms, const char *country)
Set default country variant of delivery systems like ISDB-T.
dvb_fe_is_satellite
int dvb_fe_is_satellite(uint32_t delivery_system)
DVB Ancillary routine to check if a given Delivery system is satellite.
dvb_add_parms_for_sys
int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Make dvb properties reflect the current standard.
dvb_fe_retrieve_stats
int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t *value)
Retrieve the stats for a DTV layer from cache.
dvb_fe_store_parm
int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t value)
Stores the value of a DVBv5/libdvbv5 property.
dvb_fe_retrieve_ber
float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer, enum fecap_scale_params *scale)
Retrieve the BER stats from cache.
dvb_fe_dummy
struct dvb_v5_fe_parms * dvb_fe_dummy(void)
Allocates a dummy frontend structure.
dvb_attr_names
const char *const * dvb_attr_names(int cmd)
Returns an string array with the valid string values associated with a DVBv5 command.
dvb_fe_snprintf_stat
int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd, char *display_name, int layer, char **buf, int *len, int *show_layer_name)
Ancillary function to sprintf on ENG format.
dvb_fe_snprintf_eng
int dvb_fe_snprintf_eng(char *buf, int len, float val)
Ancillary function to sprintf on ENG format.
dvb_fe_get_parms
int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
dvb_set_compat_delivery_system
int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms, uint32_t desired_system)
Sets the delivery system.
dvb_fe_lnb_high_voltage
int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on)
DVB ioctl wrapper for setting LNBf high voltage.
dvb_fe_retrieve_per
float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer)
Retrieve the PER stats from cache.
dvb_fe_sec_voltage
int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18)
DVB ioctl wrapper for setting SEC voltage.
dvb_fe_diseqc_reply
int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf, int timeout)
DVB ioctl wrapper for getting SEC DiSEqC reply.
dvb_quality
dvb_quality
Provides an estimation about the user's experience while watching to a given MPEG stream.
Definition dvb-v5-std.h:231
dvb_fe_retrieve_parm
int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t *value)
Retrieves the value of a DVBv5/libdvbv5 property.
dvb_fe_open
struct dvb_v5_fe_parms * dvb_fe_open(int adapter, int frontend, unsigned verbose, unsigned use_legacy_call)
Opens a frontend and allocates a structure to work with.
dvb_fe_sec_tone
int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
DVB ioctl wrapper for setting SEC tone.
MAX_DELIVERY_SYSTEMS
#define MAX_DELIVERY_SYSTEMS
Max number of delivery systems for a given frontend.
Definition dvb-fe.h:71
dvb_fe_retrieve_quality
enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms, unsigned layer)
Retrieve the quality stats from cache.
dvb_fe_open2
struct dvb_v5_fe_parms * dvb_fe_open2(int adapter, int frontend, unsigned verbose, unsigned use_legacy_call, dvb_logfunc logfunc)
Opens a frontend and allocates a structure to work with.
dvb_fe_get_event
int dvb_fe_get_event(struct dvb_v5_fe_parms *parms)
Get both status statistics and dvb parameters.
dvb_cmd_name
const char * dvb_cmd_name(int cmd)
Returns the string name associated with a DVBv5 command.
dvb_fe_close
void dvb_fe_close(struct dvb_v5_fe_parms *parms)
Closes the frontend and frees allocated resources.
dvb_set_sys
int dvb_set_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Sets the delivery system.
dvb_fe_retrieve_stats_layer
struct dtv_stats * dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms, unsigned cmd, unsigned layer)
Retrieve the stats for a DTV layer from cache.
dvb_fe_set_parms
int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
dvb_fe_diseqc_burst
int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b)
DVB ioctl wrapper for setting SEC DiSeqC tone burst to select between satellite A or B.
dvb_fe_prt_parms
void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
dvb_fe_open_flags
struct dvb_v5_fe_parms * dvb_fe_open_flags(int adapter, int frontend, unsigned verbose, unsigned use_legacy_call, dvb_logfunc logfunc, int flags)
Opens a frontend and allocates a structure to work with.
dvb_fe_diseqc_cmd
int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len, const unsigned char *buf)
DVB ioctl wrapper for setting SEC DiSeqC command.
dvb_fe_get_stats
int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms)
Retrieve the stats from the Kernel.
dvb_sat_lnb
Stores the information of a LNBf.
Definition dvb-sat.h:53
dvb_v5_fe_parms
Keeps data needed to handle the DVB frontend.
Definition dvb-fe.h:117
dvb_v5_fe_parms::lna
int lna
Definition dvb-fe.h:133
dvb_v5_fe_parms::legacy_fe
int legacy_fe
Definition dvb-fe.h:125
dvb_v5_fe_parms::abort
int abort
Definition dvb-fe.h:130
dvb_v5_fe_parms::freq_bpf
unsigned freq_bpf
Definition dvb-fe.h:138
dvb_v5_fe_parms::has_v5_stats
int has_v5_stats
Definition dvb-fe.h:121
dvb_v5_fe_parms::diseqc_wait
unsigned diseqc_wait
Definition dvb-fe.h:139
dvb_v5_fe_parms::num_systems
int num_systems
Definition dvb-fe.h:123
dvb_v5_fe_parms::verbose
unsigned verbose
Definition dvb-fe.h:142
dvb_v5_fe_parms::default_charset
char * default_charset
Definition dvb-fe.h:146
dvb_v5_fe_parms::sat_number
int sat_number
Definition dvb-fe.h:137
dvb_v5_fe_parms::info
struct dvb_frontend_info info
Definition dvb-fe.h:119
dvb_v5_fe_parms::output_charset
char * output_charset
Definition dvb-fe.h:147
dvb_v5_fe_parms::systems
fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS]
Definition dvb-fe.h:124
dvb_v5_fe_parms::logfunc
dvb_logfunc logfunc
Definition dvb-fe.h:143
dvb_v5_fe_parms::lnb
const struct dvb_sat_lnb * lnb
Definition dvb-fe.h:136
dvb_v5_fe_parms::version
uint32_t version
Definition dvb-fe.h:120
dvb_v5_fe_parms::current_sys
fe_delivery_system_t current_sys
Definition dvb-fe.h:122