libdvbv5 1.24.1 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 modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation version 2.1 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17 *
18 */
19#ifndef _DVB_FE_H
20#define _DVB_FE_H
21
22#include <stdio.h>
23#include <errno.h>
24#include <stdint.h>
25#include <stdlib.h>
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <fcntl.h>
29#include <sys/ioctl.h>
30#include <string.h>
31#include "dvb-frontend.h"
32#include "dvb-sat.h"
33#include "dvb-log.h"
34
64#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
65
71#define MAX_DELIVERY_SYSTEMS 20
72
73#ifndef _DOXYGEN
74/*
75 * There are a few aliases for other properties. Those are needed just
76 * to avoid breaking apps that depend on the library but shoudn't be used
77 * anymore on newer apps.
78 */
79#define DTV_MAX_STATS DTV_NUM_STATS_PROPS
80#define DTV_SIGNAL_STRENGTH DTV_STAT_SIGNAL_STRENGTH
81#define DTV_SNR DTV_STAT_CNR
82#define DTV_UNCORRECTED_BLOCKS DTV_STAT_ERROR_BLOCK_COUNT
83
84#endif
85
117 struct dvb_v5_fe_parms {
118 /* Information visible to the client - don't override those values */
119 struct dvb_frontend_info info;
120 uint32_t version;
121 int has_v5_stats;
122 fe_delivery_system_t current_sys;
123 int num_systems;
124 fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS];
125 int legacy_fe;
126
127 /* The values below are specified by the library client */
128
129 /* Flags from the client to the library */
130 int abort;
131
132 /* Linear Amplifier settings */
133 int lna;
134
135 /* Satellite settings */
136 const struct dvb_sat_lnb *lnb;
137 int sat_number;
138 unsigned freq_bpf;
139 unsigned diseqc_wait;
140
141 /* Function to write DVB logs */
142 unsigned verbose;
143 dvb_logfunc logfunc;
144
145 /* Charsets to be used by the conversion utilities */
146 char *default_charset;
147 char *output_charset;
148};
149
150#ifdef __cplusplus
151 extern "C" {
152#endif
153
163 struct dvb_v5_fe_parms *dvb_fe_dummy(void);
164
194 struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
195 unsigned verbose,
196 unsigned use_legacy_call,
197 dvb_logfunc logfunc,
198 int flags);
199
217 struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
218 unsigned verbose,
219 unsigned use_legacy_call);
220
241 struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
242 unsigned verbose, unsigned use_legacy_call,
243 dvb_logfunc logfunc);
244
251 void dvb_fe_close(struct dvb_v5_fe_parms *parms);
252
267 const char *dvb_cmd_name(int cmd);
268
283 const char *const *dvb_attr_names(int cmd);
284
285/* Get/set delivery system parameters */
286
300 int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
301 unsigned cmd, uint32_t *value);
302
316 int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
317 unsigned cmd, uint32_t value);
318
334 int dvb_set_sys(struct dvb_v5_fe_parms *parms,
335 fe_delivery_system_t sys);
336
351 int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
352 fe_delivery_system_t sys);
353
373 int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
374 uint32_t desired_system);
375
384 void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
385
398 int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
399
411 int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
412
413/*
414 * statistics functions
415 */
416
440 struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
441 unsigned cmd, unsigned layer);
442
457 int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
458 unsigned cmd, uint32_t *value);
459
470 int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
471
497 float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
498 enum fecap_scale_params *scale);
499
522 float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
523
524
548 enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
549 unsigned layer);
550
565 int dvb_fe_snprintf_eng(char *buf, int len, float val);
566
567
589 int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
590 char *display_name, int layer,
591 char **buf, int *len, int *show_layer_name);
592
603 int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
604
605/*
606 * Other functions, associated to SEC/LNB/DISEqC
607 *
608 * The functions below are just wrappers for the Kernel calls, in order to
609 * manually control satellite systems.
610 *
611 * Instead of using most them, the best is to set the LNBf parameters, and let
612 * the libdvbv5 to automatically handle the calls.
613 *
614 * NOTE: It currently lacks support for two ioctl's:
615 * FE_DISEQC_RESET_OVERLOAD used only on av7110.
616 * Spec says:
617 * If the bus has been automatically powered off due to power overload,
618 * this ioctl call restores the power to the bus. The call requires read/write
619 * access to the device. This call has no effect if the device is manually
620 * powered off. Not all DVB adapters support this ioctl.
621 *
622 * FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
623 * Spec says:
624 * WARNING: This is a very obscure legacy command, used only at stv0299
625 * driver. Should not be used on newer drivers.
626 * It provides a non-standard method for selecting Diseqc voltage on the
627 * frontend, for Dish Network legacy switches.
628 * As support for this ioctl were added in 2004, this means that such dishes
629 * were already legacy in 2004.
630 *
631 * So, it doesn't make much sense on implementing support for them.
632 */
633
646 int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
647
657 int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
658
668 int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
669
684 int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
685
696 int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
697 const unsigned char *buf);
698
710 int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
711 int timeout);
712
719 int dvb_fe_is_satellite(uint32_t delivery_system);
720
734 int dvb_fe_set_default_country(struct dvb_v5_fe_parms *parms,
735 const char *country);
736
737#ifdef __cplusplus
738}
739#endif
740
741/*
742 * Arrays from dvb-v5.h
743 *
744 * Those arrays can be used to translate from a DVB property into a name.
745 *
746 * No need to directly access them from userspace, as dvb_attr_names()
747 * already handles them into a more standard way.
748 */
749
750#ifndef _DOXYGEN
751
752 extern const unsigned fe_bandwidth_name[8];
753 extern const char *dvb_v5_name[72];
754 extern const void *dvb_v5_attr_names[];
755 extern const char *delivery_system_name[21];
756 extern const char *fe_code_rate_name[30];
757 extern const char *fe_modulation_name[22];
758 extern const char *fe_transmission_mode_name[10];
759 extern const unsigned fe_bandwidth_name[8];
760 extern const char *fe_guard_interval_name[13];
761 extern const char *fe_hierarchy_name[6];
762 extern const char *fe_voltage_name[4];
763 extern const char *fe_tone_name[3];
764 extern const char *fe_inversion_name[4];
765 extern const char *fe_pilot_name[4];
766 extern const char *fe_rolloff_name[8];
767
768#endif
769
770#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