libdvbv5 1.26.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
118 /* Information visible to the client - don't override those values */
119 struct dvb_frontend_info info;
120 uint32_t version;
122 fe_delivery_system_t current_sys;
124 fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS];
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;
138 unsigned freq_bpf;
139 unsigned diseqc_wait;
140
141 /* Function to write DVB logs */
142 unsigned verbose;
144
145 /* Charsets to be used by the conversion utilities */
148};
149
150#ifdef __cplusplus
151extern "C" {
152#endif
153
164
194struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
195 unsigned verbose,
196 unsigned use_legacy_call,
198 int flags);
199
217struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
218 unsigned verbose,
219 unsigned use_legacy_call);
220
241struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
242 unsigned verbose, unsigned use_legacy_call,
244
251void dvb_fe_close(struct dvb_v5_fe_parms *parms);
252
267const char *dvb_cmd_name(int cmd);
268
283const char *const *dvb_attr_names(int cmd);
284
285/* Get/set delivery system parameters */
286
300int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
301 unsigned cmd, uint32_t *value);
302
317 unsigned cmd, uint32_t value);
318
334int dvb_set_sys(struct dvb_v5_fe_parms *parms,
335 fe_delivery_system_t sys);
336
352 fe_delivery_system_t sys);
353
374 uint32_t desired_system);
375
384void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
385
399
412
413/*
414 * statistics functions
415 */
416
440struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
441 unsigned cmd, unsigned layer);
442
458 unsigned cmd, uint32_t *value);
459
471
497float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
498 enum fecap_scale_params *scale);
499
522float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
523
524
549 unsigned layer);
550
565int 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
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
646int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
647
657int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
658
668int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
669
684int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
685
696int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
697 const unsigned char *buf);
698
710int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
711 int timeout);
712
719int dvb_fe_is_satellite(uint32_t delivery_system);
720
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
752extern const unsigned fe_bandwidth_name[8];
753extern const char *dvb_v5_name[72];
754extern const void *dvb_v5_attr_names[];
755extern const char *delivery_system_name[21];
756extern const char *fe_code_rate_name[34];
757extern const char *fe_modulation_name[22];
758extern const char *fe_transmission_mode_name[10];
759extern const unsigned fe_bandwidth_name[8];
760extern const char *fe_guard_interval_name[13];
761extern const char *fe_hierarchy_name[6];
762extern const char *fe_voltage_name[4];
763extern const char *fe_tone_name[3];
764extern const char *fe_inversion_name[4];
765extern const char *fe_pilot_name[4];
766extern const char *fe_rolloff_name[8];
767
768#endif
769
770#endif
Provides interfaces to handle libdvbv5 log messages.
void(* dvb_logfunc)(int level, const char *fmt,...)
Definition dvb-log.h:44
Provides interfaces to deal with DVB Satellite systems.
dvb_quality
Definition dvb-v5-std.h:231
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.
int dvb_fe_is_satellite(uint32_t delivery_system)
DVB Ancillary routine to check if a given Delivery system is satellite.
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_retrieve_stats(struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t *value)
Retrieve the stats for a DTV layer from cache.
int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t value)
Stores the value of a DVBv5/libdvbv5 property.
float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer, enum fecap_scale_params *scale)
Retrieve the BER stats from cache.
struct dvb_v5_fe_parms * dvb_fe_dummy(void)
Allocates a dummy frontend structure.
const char *const * dvb_attr_names(int cmd)
Returns an string array with the valid string values associated with a DVBv5 command.
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_snprintf_eng(char *buf, int len, float val)
Ancillary function to sprintf on ENG format.
int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms, uint32_t desired_system)
Sets the delivery system.
int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on)
DVB ioctl wrapper for setting LNBf high voltage.
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 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_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t *value)
Retrieves the value of a DVBv5/libdvbv5 property.
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.
int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
DVB ioctl wrapper for setting SEC tone.
#define MAX_DELIVERY_SYSTEMS
Max number of delivery systems for a given frontend.
Definition dvb-fe.h:71
enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms, unsigned layer)
Retrieve the quality stats from cache.
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_get_event(struct dvb_v5_fe_parms *parms)
Get both status statistics and dvb parameters.
const char * dvb_cmd_name(int cmd)
Returns the string name associated with a DVBv5 command.
void dvb_fe_close(struct dvb_v5_fe_parms *parms)
Closes the frontend and frees allocated resources.
int dvb_set_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
Sets the delivery system.
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_fe_set_parms(struct dvb_v5_fe_parms *parms)
Prints all the properties at the cache.
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.
void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms)
Prints all the properties at the 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_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_get_stats(struct dvb_v5_fe_parms *parms)
Retrieve the stats from the Kernel.
Stores the information of a LNBf.
Definition dvb-sat.h:53
Keeps data needed to handle the DVB frontend.
Definition dvb-fe.h:117
unsigned freq_bpf
Definition dvb-fe.h:138
unsigned diseqc_wait
Definition dvb-fe.h:139
unsigned verbose
Definition dvb-fe.h:142
char * default_charset
Definition dvb-fe.h:146
struct dvb_frontend_info info
Definition dvb-fe.h:119
char * output_charset
Definition dvb-fe.h:147
fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS]
Definition dvb-fe.h:124
dvb_logfunc logfunc
Definition dvb-fe.h:143
const struct dvb_sat_lnb * lnb
Definition dvb-fe.h:136
uint32_t version
Definition dvb-fe.h:120
fe_delivery_system_t current_sys
Definition dvb-fe.h:122