libdvbv5  1.4.0
Library to work with Digital TV streams
Data Structures | Macros | Functions
dvb-fe.h File Reference

Provides interfaces to deal with DVB frontend. More...

#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"
Include dependency graph for dvb-fe.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dvb_v5_fe_parms
 Keeps data needed to handle the DVB frontend. More...
 

Macros

#define ARRAY_SIZE(x)
 Calculates the number of elements of an array. More...
 
#define MAX_DELIVERY_SYSTEMS
 Max number of delivery systems for a given frontend. More...
 

Functions

struct dvb_v5_fe_parmsdvb_fe_dummy (void)
 Allocates a dummy frontend structure. More...
 
struct dvb_v5_fe_parmsdvb_fe_open (int adapter, int frontend, unsigned verbose, unsigned use_legacy_call)
 Opens a frontend and allocates a structure to work with. More...
 
struct dvb_v5_fe_parmsdvb_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. More...
 
void dvb_fe_close (struct dvb_v5_fe_parms *parms)
 Closes the frontend and frees allocated resources. More...
 
const char * dvb_cmd_name (int cmd)
 Returns the string name associated with a DVBv5 command. More...
 
const char *const * dvb_attr_names (int cmd)
 Returns an string array with the valid string values associated with a DVBv5 command. More...
 
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. More...
 
int dvb_fe_store_parm (struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t value)
 Stores the value of a DVBv5/libdvbv5 property. More...
 
int dvb_set_sys (struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
 Sets the delivery system. More...
 
int dvb_add_parms_for_sys (struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys)
 Make dvb properties reflect the current standard. More...
 
int dvb_set_compat_delivery_system (struct dvb_v5_fe_parms *parms, uint32_t desired_system)
 Sets the delivery system. More...
 
void dvb_fe_prt_parms (const struct dvb_v5_fe_parms *parms)
 Prints all the properties at the cache. More...
 
int dvb_fe_set_parms (struct dvb_v5_fe_parms *parms)
 Prints all the properties at the cache. More...
 
int dvb_fe_get_parms (struct dvb_v5_fe_parms *parms)
 Prints all the properties at the cache. More...
 
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. More...
 
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. More...
 
int dvb_fe_get_stats (struct dvb_v5_fe_parms *parms)
 Retrieve the stats from the Kernel. More...
 
float dvb_fe_retrieve_ber (struct dvb_v5_fe_parms *parms, unsigned layer, enum fecap_scale_params *scale)
 Retrieve the BER stats from cache. More...
 
float dvb_fe_retrieve_per (struct dvb_v5_fe_parms *parms, unsigned layer)
 Retrieve the PER stats from cache. More...
 
int dvb_fe_snprintf_eng (char *buf, int len, float val)
 Ancillary function to sprintf on ENG format. More...
 
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)
 Get both status statistics and dvb parameters. More...
 
int dvb_fe_sec_voltage (struct dvb_v5_fe_parms *parms, int on, int v18)
 DVB ioctl wrapper for setting SEC voltage. More...
 
int dvb_fe_sec_tone (struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone)
 DVB ioctl wrapper for setting SEC tone. More...
 
int dvb_fe_lnb_high_voltage (struct dvb_v5_fe_parms *parms, int on)
 DVB ioctl wrapper for setting LNBf high voltage. More...
 
int dvb_fe_diseqc_burst (struct dvb_v5_fe_parms *parms, int mini_b)
 DVB ioctl wrapper for setting SEC DiSeqC burst. More...
 
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. More...
 
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. More...
 
int dvb_fe_is_satellite (uint32_t delivery_system)
 DVB Ancillary routine to check if a given Delivery system is satellite. More...
 

Detailed Description

Provides interfaces to deal with DVB frontend.

Author
Mauro Carvalho Chehab

The libdvbv5 API works with a set of key/value properties. There are two types of properties:

Just like the DTV properties, the stats are cached. That warrants that all stats are got at the same time, when dvb_fe_get_stats() is called.

Please submit bug report and patches to linux.nosp@m.-med.nosp@m.ia@vg.nosp@m.er.k.nosp@m.ernel.nosp@m..org

Definition in file dvb-fe.h.

Macro Definition Documentation

#define ARRAY_SIZE (   x)

Calculates the number of elements of an array.

Definition at line 62 of file dvb-fe.h.

#define MAX_DELIVERY_SYSTEMS

Max number of delivery systems for a given frontend.

Definition at line 68 of file dvb-fe.h.

Function Documentation

int dvb_add_parms_for_sys ( struct dvb_v5_fe_parms parms,
fe_delivery_system_t  sys 
)

Make dvb properties reflect the current standard.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
sysdelivery system to be selected

This function prepares the properties cache for a given delivery system.

It is automatically called by dvb_set_sys(), and should not be normally called, except when dvb_fe_dummy() is used.

Returns
Return 0 if success, EINVAL otherwise.
const char *const * dvb_attr_names ( int  cmd)

Returns an string array with the valid string values associated with a DVBv5 command.

Parameters
cmdDVBv5 or libdvbv5 property
Returns
it returns a string array that corresponds to the names associated with the possible values for that property, when available. For example: dvb_cmd_name(DTV_CODE_RATE_HP) would return an array with the possible values for the code rates: { "1/2", "2/3", ... NULL }
Note
: The array always ends with NULL.
const char * dvb_cmd_name ( int  cmd)

Returns the string name associated with a DVBv5 command.

Parameters
cmdDVBv5 or libdvbv5 property

This function gets an integer argument (cmd) and returns a string that corresponds to the name of that property.

Returns
it returns a string that corresponds to the property name. For example: dvb_cmd_name(DTV_GUARD_INTERVAL) would return "GUARD_INTERVAL" It also returns names for the properties used internally by libdvbv5.
void dvb_fe_close ( struct dvb_v5_fe_parms parms)

Closes the frontend and frees allocated resources.

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_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_diseqc_reply ( struct dvb_v5_fe_parms parms,
unsigned *  len,
char *  buf,
int  timeout 
)

DVB ioctl wrapper for getting SEC DiSeqC reply.

struct dvb_v5_fe_parms * dvb_fe_dummy ( void  )

Allocates a dummy frontend structure.

This is useful for some applications that may want to just use the frontend structure internally, without associating it with a real hardware

Returns
Returns a pointer to a dummy struct, or NULL if no memory.
int dvb_fe_get_event ( struct dvb_v5_fe_parms parms)

Get both status statistics and dvb parameters.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device

That's similar of calling both dvb_fe_get_parms() and dvb_fe_get_stats().

Returns
It returns 0 if success or an errorno otherwise.
int dvb_fe_get_parms ( struct dvb_v5_fe_parms parms)

Prints all the properties at the cache.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device

Gets the properties from the DVB hardware. The values will only reflect what's set at the hardware if the frontend is locked.

Returns
Return 0 if success, EINVAL otherwise.
int dvb_fe_get_stats ( struct dvb_v5_fe_parms parms)

Retrieve the stats from the Kernel.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device

Updates the stats cache from the available stats at the Kernel.

Returns
The returned value is 0 if success, EINVAL otherwise.
int dvb_fe_is_satellite ( uint32_t  delivery_system)

DVB Ancillary routine to check if a given Delivery system is satellite.

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_open ( int  adapter,
int  frontend,
unsigned  verbose,
unsigned  use_legacy_call 
)

Opens a frontend and allocates a structure to work with.

Parameters
adapterNumber of the adapter to open
frontendNumber of the frontend to open
verboseVerbosity level of the messages that will be printed
use_legacy_callForce to use the DVBv3 calls, instead of using the DVBv5 API

This function should be called before using any other function at the frontend library (or the other alternatives: dvb_fe_open2() or dvb_fe_dummy().

Returns
Returns a pointer to an allocated data pointer or NULL on error.
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.

Parameters
adapterNumber of the adapter to open
frontendNumber of the frontend to open
verboseVerbosity level of the messages that will be printed
use_legacy_callForce to use the DVBv3 calls, instead of using the DVBv5 API
logfuncCallback function to be called when a log event happens. Can either store the event into a file or to print it at the TUI/GUI.

This function should be called before using any other function at the frontend library (or the other alternatives: dvb_fe_open() or dvb_fe_dummy().

Returns
Returns a pointer to an allocated data pointer or NULL on error.
void dvb_fe_prt_parms ( const struct dvb_v5_fe_parms parms)

Prints all the properties at the cache.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device

Used mostly for debugging issues.

float dvb_fe_retrieve_ber ( struct dvb_v5_fe_parms parms,
unsigned  layer,
enum fecap_scale_params *  scale 
)

Retrieve the BER stats from cache.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
layerDTV layer
scaleretrieves the scale

Gets the value for BER stats from stats cache, on a given layer. Layer 0 is always present. On DTV standards that doesn't have layers, it returns the same value as dvb_fe_retrieve_stats() for layer = 0.

For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A', layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all frontends support per-layer stats. Also, the layer value is only valid if the layer exists at the original stream. Also, on such standards, layer 0 is typically a mean value of the layers, or a sum of events (if FE_SCALE_COUNTER).

For it to be valid, dvb_fe_get_stats() should be called first.

Returns
It returns a float number for the BER value. If the statistics is not available for any reason, scale will be equal to FE_SCALE_NOT_AVAILABLE.
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.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
cmdDVBv5 or libdvbv5 property
valuePointer to an uint32_t where the value will be stored.

This reads the value of a property stored at the cache. Before using it, a dvb_fe_get_parms() is likely required.

Returns
Return 0 if success, EINVAL otherwise.
float dvb_fe_retrieve_per ( struct dvb_v5_fe_parms parms,
unsigned  layer 
)

Retrieve the PER stats from cache.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
layerDTV layer

Gets the value for BER stats from stats cache, on a given layer. Layer 0 is always present. On DTV standards that doesn't have layers, it returns the same value as dvb_fe_retrieve_stats() for layer = 0.

For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A', layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all frontends support per-layer stats. Also, the layer value is only valid if the layer exists at the original stream. Also, on such standards, layer 0 is typically a mean value of the layers, or a sum of events (if FE_SCALE_COUNTER).

For it to be valid, dvb_fe_get_stats() should be called first.

Returns
A negative value indicates error.
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.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
cmdDVBv5 or libdvbv5 property
valueDTV value pointer

Gets the value for one stats property for layer = 0.

For it to be valid, dvb_fe_get_stats() should be called first.

Returns
The returned value is 0 if success, EINVAL otherwise.
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.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
cmdDVBv5 or libdvbv5 property
layerDTV layer

Gets the value for one stats cache, on a given layer. Layer 0 is always present. On DTV standards that doesn't have layers, it returns the same value as dvb_fe_retrieve_stats() for layer = 0.

For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A', layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all frontends support per-layer stats. Also, the layer value is only valid if the layer exists at the original stream. Also, on such standards, layer 0 is typically a mean value of the layers, or a sum of events (if FE_SCALE_COUNTER).

For it to be valid, dvb_fe_get_stats() should be called first.

Returns
It returns a struct dtv_stats if succeed or NULL otherwise.
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_sec_voltage ( struct dvb_v5_fe_parms parms,
int  on,
int  v18 
)

DVB ioctl wrapper for setting SEC voltage.

int dvb_fe_set_parms ( struct dvb_v5_fe_parms parms)

Prints all the properties at the cache.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device

Writes the properties stored at the DVB cache at the DVB hardware. At return, some properties could have a different value, as the frontend may not support the values set.

Returns
Return 0 if success, EINVAL otherwise.
int dvb_fe_snprintf_eng ( char *  buf,
int  len,
float  val 
)

Ancillary function to sprintf on ENG format.

Parameters
bufbuffer to store the value
lenbuffer length
valvalue to be printed

On ENG notation, the exponential value should be multiple of 3. This is good to display some values, like BER.

Returns
At return, it shows the actual size of the print. A negative value indicates an error.
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_store_parm ( struct dvb_v5_fe_parms parms,
unsigned  cmd,
uint32_t  value 
)

Stores the value of a DVBv5/libdvbv5 property.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
cmdDVBv5 or libdvbv5 property
valuePointer to an uint32_t where the value will be stored.

This stores the value of a property at the cache. The value will only be send to the hardware after calling dvb_fe_set_parms().

Returns
Return 0 if success, EINVAL otherwise.
int dvb_set_compat_delivery_system ( struct dvb_v5_fe_parms parms,
uint32_t  desired_system 
)

Sets the delivery system.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
desired_systemdelivery system to be selected

This function changes the delivery system of the frontend. By default, the libdvbv5 will use the first available delivery system. If another delivery system is desirable, this function should be called before being able to store the properties for the new delivery system via dvb_fe_store_parm().

This function is an enhanced version of dvb_set_sys(): it has an special logic inside to work with Kernels that supports onld DVBv3.

Returns
Return 0 if success, EINVAL otherwise.
int dvb_set_sys ( struct dvb_v5_fe_parms parms,
fe_delivery_system_t  sys 
)

Sets the delivery system.

Parameters
parmsstruct dvb_v5_fe_parms pointer to the opened device
sysdelivery system to be selected

This function changes the delivery system of the frontend. By default, the libdvbv5 will use the first available delivery system. If another delivery system is desirable, this function should be called before being able to store the properties for the new delivery system via dvb_fe_store_parm().

Returns
Return 0 if success, EINVAL otherwise.