libdvbv5  1.4.0
Library to work with Digital TV streams
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 
62 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
63 
68 #define MAX_DELIVERY_SYSTEMS 20
69 
70 #ifndef _DOXYGEN
71 /*
72  * There are a few aliases for other properties. Those are needed just
73  * to avoid breaking apps that depend on the library but shoudn't be used
74  * anymore on newer apps.
75  */
76 #define DTV_MAX_STATS DTV_NUM_STATS_PROPS
77 #define DTV_SIGNAL_STRENGTH DTV_STAT_SIGNAL_STRENGTH
78 #define DTV_SNR DTV_STAT_CNR
79 #define DTV_UNCORRECTED_BLOCKS DTV_STAT_ERROR_BLOCK_COUNT
80 
81 #endif
82 
114  /* Information visible to the client - don't override those values */
115  struct dvb_frontend_info info;
116  uint32_t version;
118  fe_delivery_system_t current_sys;
120  fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS];
122 
123  /* The values below are specified by the library client */
124 
125  /* Flags from the client to the library */
126  int abort;
127 
128  /* Linear Amplifier settings */
129  int lna;
130 
131  /* Satellite settings */
132  const struct dvb_sat_lnb *lnb;
134  unsigned freq_bpf;
135  unsigned diseqc_wait;
136 
137  /* Function to write DVB logs */
138  unsigned verbose;
140 
141  /* Charsets to be used by the conversion utilities */
144 };
145 
146 #ifdef __cplusplus
147 extern "C" {
148 #endif
149 
159 struct dvb_v5_fe_parms *dvb_fe_dummy(void);
160 
178 struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
179  unsigned verbose, unsigned use_legacy_call);
180 
202 struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
203  unsigned verbose, unsigned use_legacy_call,
205 
210 void dvb_fe_close(struct dvb_v5_fe_parms *parms);
211 
226 const char *dvb_cmd_name(int cmd);
227 
242 const char *const *dvb_attr_names(int cmd);
243 
244 /* Get/set delivery system parameters */
245 
260 int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
261  unsigned cmd, uint32_t *value);
262 
277 int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
278  unsigned cmd, uint32_t value);
279 
296 int dvb_set_sys(struct dvb_v5_fe_parms *parms,
297  fe_delivery_system_t sys);
298 
314 int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
315  fe_delivery_system_t sys);
316 
338  uint32_t desired_system);
339 
348 void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
349 
362 int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
363 
375 int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
376 
377 /*
378  * statistics functions
379  */
380 
405 struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
406  unsigned cmd, unsigned layer);
407 
423 int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
424  unsigned cmd, uint32_t *value);
425 
436 int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
437 
464 float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
465  enum fecap_scale_params *scale);
466 
489 float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
490 
505 int dvb_fe_snprintf_eng(char *buf, int len, float val);
506 
507 
531  int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
532  char *display_name, int layer,
533  char **buf, int *len, int *show_layer_name);
534 
545 int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
546 
547 /*
548  * Other functions, associated to SEC/LNB/DISEqC
549  *
550  * The functions bellow are just wrappers for the Kernel calls, in order to
551  * manually control satellite systems.
552  *
553  * Instead of using them, the best is to set the LNBf parameters, and let
554  * the libdvbv5 to automatically handle the calls.
555  *
556  * NOTE: It currently lacks support for two ioctl's:
557  * FE_DISEQC_RESET_OVERLOAD used only on av7110.
558  * Spec says:
559  * If the bus has been automatically powered off due to power overload,
560  * this ioctl call restores the power to the bus. The call requires read/write
561  * access to the device. This call has no effect if the device is manually
562  * powered off. Not all DVB adapters support this ioctl.
563  *
564  * FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
565  * Spec says:
566  * WARNING: This is a very obscure legacy command, used only at stv0299
567  * driver. Should not be used on newer drivers.
568  * It provides a non-standard method for selecting Diseqc voltage on the
569  * frontend, for Dish Network legacy switches.
570  * As support for this ioctl were added in 2004, this means that such dishes
571  * were already legacy in 2004.
572  *
573  * So, it doesn't make much sense on implementing support for them.
574  */
575 
579 int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
580 
584 int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
585 
589 int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
590 
594 int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
595 
599 int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
600  const unsigned char *buf);
601 
605 int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
606  int timeout);
607 
611 int dvb_fe_is_satellite(uint32_t delivery_system);
612 
613 #ifdef __cplusplus
614 }
615 #endif
616 
617 /*
618  * Arrays from dvb-v5.h
619  *
620  * Those arrays can be used to translate from a DVB property into a name.
621  *
622  * No need to directly access them from userspace, as dvb_attr_names()
623  * already handles them into a more standard way.
624  */
625 
626 #ifndef _DOXYGEN
627 
628 extern const unsigned fe_bandwidth_name[8];
629 extern const char *dvb_v5_name[71];
630 extern const void *dvb_v5_attr_names[];
631 extern const char *delivery_system_name[20];
632 extern const char *fe_code_rate_name[14];
633 extern const char *fe_modulation_name[15];
634 extern const char *fe_transmission_mode_name[10];
635 extern const unsigned fe_bandwidth_name[8];
636 extern const char *fe_guard_interval_name[12];
637 extern const char *fe_hierarchy_name[6];
638 extern const char *fe_voltage_name[4];
639 extern const char *fe_tone_name[3];
640 extern const char *fe_inversion_name[4];
641 extern const char *fe_pilot_name[4];
642 extern const char *fe_rolloff_name[5];
643 
644 #endif
645 
646 #endif
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_logfunc logfunc
Definition: dvb-fe.h:139
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.
Stores the information of a LNBf.
Definition: dvb-sat.h:70
int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on)
DVB ioctl wrapper for setting LNBf high voltage.
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.
Provides interfaces to deal with DVB Satellite systems.
int sat_number
Definition: dvb-fe.h:133
int dvb_set_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Sets the delivery system.
Provides interfaces to handle libdvbv5 log messages.
unsigned freq_bpf
Definition: dvb-fe.h:134
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:143
struct dvb_v5_fe_parms * dvb_fe_dummy(void)
Allocates a dummy frontend structure.
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.
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.
unsigned verbose
Definition: dvb-fe.h:138
const char *const * dvb_attr_names(int cmd)
Returns an string array with the valid string values associated with a DVBv5 command.
int num_systems
Definition: dvb-fe.h:119
int dvb_fe_get_event(struct dvb_v5_fe_parms *parms)
Get both status statistics and dvb parameters.
#define MAX_DELIVERY_SYSTEMS
Max number of delivery systems for a given frontend.
Definition: dvb-fe.h:68
struct dvb_frontend_info info
Definition: dvb-fe.h:115
float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer)
Retrieve the PER stats from cache.
int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18)
DVB ioctl wrapper for setting SEC voltage.
int has_v5_stats
Definition: dvb-fe.h:117
int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Make dvb properties reflect the current standard.
int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
uint32_t version
Definition: dvb-fe.h:116
Keeps data needed to handle the DVB frontend.
Definition: dvb-fe.h:113
fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS]
Definition: dvb-fe.h:120
int dvb_fe_snprintf_eng(char *buf, int len, float val)
Ancillary function to sprintf on ENG format.
const struct dvb_sat_lnb * lnb
Definition: dvb-fe.h:132
unsigned diseqc_wait
Definition: dvb-fe.h:135
int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms)
Retrieve the stats from the Kernel.
void(* dvb_logfunc)(int level, const char *fmt,...)
typedef used by dvb_fe_open2 for the log function
Definition: dvb-log.h:42
void dvb_fe_close(struct dvb_v5_fe_parms *parms)
Closes the frontend and frees allocated resources.
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_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf, int timeout)
DVB ioctl wrapper for getting SEC DiSeqC reply.
int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms, uint32_t desired_system)
Sets the delivery system.
int dvb_fe_is_satellite(uint32_t delivery_system)
DVB Ancillary routine to check if a given Delivery system is satellite.
int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
char * default_charset
Definition: dvb-fe.h:142
fe_delivery_system_t current_sys
Definition: dvb-fe.h:118
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.
int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b)
DVB ioctl wrapper for setting SEC DiSeqC burst.
int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
DVB ioctl wrapper for setting SEC tone.
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.
const char * dvb_cmd_name(int cmd)
Returns the string name associated with a DVBv5 command.