libdvbv5  1.6.3
Library to work with Digital TV devices on Linux
dvb-fe.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation version 2
7  * of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  */
20 #ifndef _DVB_FE_H
21 #define _DVB_FE_H
22 
23 #include <stdio.h>
24 #include <errno.h>
25 #include <stdint.h>
26 #include <stdlib.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <fcntl.h>
30 #include <sys/ioctl.h>
31 #include <string.h>
32 #include "dvb-frontend.h"
33 #include "dvb-sat.h"
34 #include "dvb-log.h"
35 
65 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
66 
72 #define MAX_DELIVERY_SYSTEMS 20
73 
74 #ifndef _DOXYGEN
75 /*
76  * There are a few aliases for other properties. Those are needed just
77  * to avoid breaking apps that depend on the library but shoudn't be used
78  * anymore on newer apps.
79  */
80 #define DTV_MAX_STATS DTV_NUM_STATS_PROPS
81 #define DTV_SIGNAL_STRENGTH DTV_STAT_SIGNAL_STRENGTH
82 #define DTV_SNR DTV_STAT_CNR
83 #define DTV_UNCORRECTED_BLOCKS DTV_STAT_ERROR_BLOCK_COUNT
84 
85 #endif
86 
119  /* Information visible to the client - don't override those values */
120  struct dvb_frontend_info info;
121  uint32_t version;
123  fe_delivery_system_t current_sys;
125  fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS];
127 
128  /* The values below are specified by the library client */
129 
130  /* Flags from the client to the library */
131  int abort;
132 
133  /* Linear Amplifier settings */
134  int lna;
135 
136  /* Satellite settings */
137  const struct dvb_sat_lnb *lnb;
139  unsigned freq_bpf;
140  unsigned diseqc_wait;
141 
142  /* Function to write DVB logs */
143  unsigned verbose;
145 
146  /* Charsets to be used by the conversion utilities */
149 };
150 
151 #ifdef __cplusplus
152 extern "C" {
153 #endif
154 
164 struct dvb_v5_fe_parms *dvb_fe_dummy(void);
165 
195 struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
196  unsigned verbose,
197  unsigned use_legacy_call,
199  int flags);
200 
218 struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
219  unsigned verbose,
220  unsigned use_legacy_call);
221 
242 struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
243  unsigned verbose, unsigned use_legacy_call,
244  dvb_logfunc logfunc);
245 
252 void dvb_fe_close(struct dvb_v5_fe_parms *parms);
253 
268 const char *dvb_cmd_name(int cmd);
269 
284 const char *const *dvb_attr_names(int cmd);
285 
286 /* Get/set delivery system parameters */
287 
301 int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
302  unsigned cmd, uint32_t *value);
303 
317 int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
318  unsigned cmd, uint32_t value);
319 
335 int dvb_set_sys(struct dvb_v5_fe_parms *parms,
336  fe_delivery_system_t sys);
337 
352 int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
353  fe_delivery_system_t sys);
354 
375  uint32_t desired_system);
376 
385 void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
386 
399 int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
400 
412 int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
413 
414 /*
415  * statistics functions
416  */
417 
441 struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
442  unsigned cmd, unsigned layer);
443 
458 int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
459  unsigned cmd, uint32_t *value);
460 
471 int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
472 
498 float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
499  enum fecap_scale_params *scale);
500 
523 float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
524 
525 
550  unsigned layer);
551 
566 int dvb_fe_snprintf_eng(char *buf, int len, float val);
567 
568 
590  int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
591  char *display_name, int layer,
592  char **buf, int *len, int *show_layer_name);
593 
604 int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
605 
606 /*
607  * Other functions, associated to SEC/LNB/DISEqC
608  *
609  * The functions bellow are just wrappers for the Kernel calls, in order to
610  * manually control satellite systems.
611  *
612  * Instead of using most them, the best is to set the LNBf parameters, and let
613  * the libdvbv5 to automatically handle the calls.
614  *
615  * NOTE: It currently lacks support for two ioctl's:
616  * FE_DISEQC_RESET_OVERLOAD used only on av7110.
617  * Spec says:
618  * If the bus has been automatically powered off due to power overload,
619  * this ioctl call restores the power to the bus. The call requires read/write
620  * access to the device. This call has no effect if the device is manually
621  * powered off. Not all DVB adapters support this ioctl.
622  *
623  * FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
624  * Spec says:
625  * WARNING: This is a very obscure legacy command, used only at stv0299
626  * driver. Should not be used on newer drivers.
627  * It provides a non-standard method for selecting Diseqc voltage on the
628  * frontend, for Dish Network legacy switches.
629  * As support for this ioctl were added in 2004, this means that such dishes
630  * were already legacy in 2004.
631  *
632  * So, it doesn't make much sense on implementing support for them.
633  */
634 
647 int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
648 
658 int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
659 
669 int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
670 
685 int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
686 
697 int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
698  const unsigned char *buf);
699 
711 int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
712  int timeout);
713 
720 int dvb_fe_is_satellite(uint32_t delivery_system);
721 
722 #ifdef __cplusplus
723 }
724 #endif
725 
726 /*
727  * Arrays from dvb-v5.h
728  *
729  * Those arrays can be used to translate from a DVB property into a name.
730  *
731  * No need to directly access them from userspace, as dvb_attr_names()
732  * already handles them into a more standard way.
733  */
734 
735 #ifndef _DOXYGEN
736 
737 extern const unsigned fe_bandwidth_name[8];
738 extern const char *dvb_v5_name[71];
739 extern const void *dvb_v5_attr_names[];
740 extern const char *delivery_system_name[20];
741 extern const char *fe_code_rate_name[14];
742 extern const char *fe_modulation_name[15];
743 extern const char *fe_transmission_mode_name[10];
744 extern const unsigned fe_bandwidth_name[8];
745 extern const char *fe_guard_interval_name[12];
746 extern const char *fe_hierarchy_name[6];
747 extern const char *fe_voltage_name[4];
748 extern const char *fe_tone_name[3];
749 extern const char *fe_inversion_name[4];
750 extern const char *fe_pilot_name[4];
751 extern const char *fe_rolloff_name[5];
752 
753 #endif
754 
755 #endif
dvb_logfunc logfunc
Definition: dvb-fe.h:144
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.
Stores the information of a LNBf.
Definition: dvb-sat.h:74
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.
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.
int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
Provides interfaces to deal with DVB Satellite systems.
int sat_number
Definition: dvb-fe.h:138
Provides interfaces to handle libdvbv5 log messages.
unsigned freq_bpf
Definition: dvb-fe.h:139
int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t value)
Stores the value of a DVBv5/libdvbv5 property.
int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms, uint32_t desired_system)
Sets the delivery system.
float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer, enum fecap_scale_params *scale)
Retrieve the BER stats from cache.
char * output_charset
Definition: dvb-fe.h:148
unsigned verbose
Definition: dvb-fe.h:143
float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer)
Retrieve the PER stats from cache.
int num_systems
Definition: dvb-fe.h:124
void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
struct dvb_frontend_info info
Definition: dvb-fe.h:120
void(* dvb_logfunc)(int level, const char *fmt,...)
typedef used by dvb_fe_open2 for the log function
Definition: dvb-log.h:45
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.
int has_v5_stats
Definition: dvb-fe.h:122
int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
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.
int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Make dvb properties reflect the current standard.
void dvb_fe_close(struct dvb_v5_fe_parms *parms)
Closes the frontend and frees allocated resources.
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.
uint32_t version
Definition: dvb-fe.h:121
int dvb_fe_get_event(struct dvb_v5_fe_parms *parms)
Get both status statistics and dvb parameters.
const char *const * dvb_attr_names(int cmd)
Returns an string array with the valid string values associated with a DVBv5 command.
Keeps data needed to handle the DVB frontend.
Definition: dvb-fe.h:118
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.
fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS]
Definition: dvb-fe.h:125
int dvb_fe_is_satellite(uint32_t delivery_system)
DVB Ancillary routine to check if a given Delivery system is satellite.
const struct dvb_sat_lnb * lnb
Definition: dvb-fe.h:137
int dvb_set_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Sets the delivery system.
unsigned diseqc_wait
Definition: dvb-fe.h:140
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.
int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18)
DVB ioctl wrapper for setting SEC voltage.
#define MAX_DELIVERY_SYSTEMS
Max number of delivery systems for a given frontend.
Definition: dvb-fe.h:72
int dvb_fe_snprintf_eng(char *buf, int len, float val)
Ancillary function to sprintf on ENG format.
int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
DVB ioctl wrapper for setting SEC tone.
int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms)
Retrieve the stats from the Kernel.
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.
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...
enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms, unsigned layer)
Retrieve the quality stats from cache.
char * default_charset
Definition: dvb-fe.h:147
int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on)
DVB ioctl wrapper for setting LNBf high voltage.
struct dvb_v5_fe_parms * dvb_fe_dummy(void)
Allocates a dummy frontend structure.
dvb_quality
Provides an estimation about the user's experience while watching to a given MPEG stream...
Definition: dvb-v5-std.h:227
fe_delivery_system_t current_sys
Definition: dvb-fe.h:123
const char * dvb_cmd_name(int cmd)
Returns the string name associated with a DVBv5 command.