Commit f12d6405 authored by Christophe Massiot's avatar Christophe Massiot

* modules/access/dvb: Major rewrite of the code.

  - new options (now prepended with --dvb) :
     --dvb-program : to work around the non-working --program
     --dvb-inversion : to (optionally) specify the inversion, which is not
                       the same as polarization
     --dvb-budget-mode : if you have a budget card this will set a filter
                         on 0x2000, meaning all PIDs will be returned by
                         the driver. The budget-mode is compatible with demux2.
     --dvb-satno : to specify a sat number in the diseqc system
     --dvb-voltage : to specify the voltage of the LNB (0 is a permitted
                     value in special configurations)
     --dvb-tone : to enable/disable the 22kHz tone (by default it is sent
                  if frequency >= lnb-slof)
  - fixed a handful of QPSK tuning bugs, especially the diseqc was not
    working and frequencies above 11700 couldn't be tuned to.
  - the modules now uses the inherited object variables for its
    configuration.
  - symbol-rate= url option is now srate= for consistency with the
    configuration variable.
  - all linux-dvb specific code is now in linux_dvb.c. access.c contains
    only code which could be reused on other platforms.
  - better keep track of demux file descriptors (especially useful on
    limited boards).
  - do not block in read() when no data is available.
  - fixed msleep() calls (reminder : mtime_t is in _microseconds_).

I didn't test the QAM and OFDM variants, so please report.
parent 2a6648ee
SOURCES_dvb = \
qpsk.c \
access.c \
dvb.c \
linux_dvb.c \
dvb.h \
$(NULL)
/*****************************************************************************
* access.c: DVB card input v4l2 only
*****************************************************************************
* Copyright (C) 1998-2003 VideoLAN
* Copyright (C) 1998-2004 VideoLAN
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@wxs.nl>
* Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -49,10 +50,6 @@
# include <strings.h>
#endif
/* DVB Card Drivers */
#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
#include "dvb.h"
#define SATELLITE_READ_ONCE 3
......@@ -60,237 +57,287 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
static int Open( vlc_object_t *p_this );
static void Close( vlc_object_t *p_this );
static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len);
static int SatelliteSetArea ( input_thread_t *, input_area_t * );
static int SatelliteSetProgram ( input_thread_t *, pgrm_descriptor_t * );
static void SatelliteSeek ( input_thread_t *, off_t );
static int SetArea ( input_thread_t *, input_area_t * );
static int SetProgram ( input_thread_t *, pgrm_descriptor_t * );
static void Seek ( input_thread_t *, off_t );
static void AllocateDemux( input_thread_t * p_input, int i_pid,
int i_type );
static void CloseProgram( input_thread_t * p_input );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define PROGRAM_TEXT N_("Program to decode")
#define PROGRAM_LONGTEXT N_("This is a workaround for a bug in the input")
#define ADAPTER_TEXT N_("Adapter card to tune")
#define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.")
#define DEVICE_TEXT N_("Device number to use on adapter")
#define DEVICE_LONGTEXT ""
#define FREQ_TEXT N_("Transponder/multiplex frequency")
#define FREQ_LONGTEXT N_("In kHz for DVB-S or Hz for DVB-C/T")
#define INVERSION_TEXT N_("Inversion mode")
#define INVERSION_LONGTEXT N_("Inversion mode [0=off, 1=on, 2=auto]")
#define PROBE_TEXT N_("Probe DVB card for capabilities")
#define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities.")
#define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
#define LNB_LOF1_LONGTEXT ""
#define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
#define LNB_LOF2_LONGTEXT ""
#define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
#define LNB_SLOF_LONGTEXT ""
/* Satellite */
#define BUDGET_TEXT N_("Budget mode")
#define BUDGET_LONGTEXT N_("This allows you to stream an entire transponder with a budget card. Budget mode is compatible with the ts2 demux.")
#define SATNO_TEXT N_("Satellite number in the Diseqc system")
#define SATNO_LONGTEXT N_("[0=no diseqc, 1-4=normal diseqc, -1=A, -2=B simple diseqc")
#define VOLTAGE_TEXT N_("LNB voltage")
#define VOLTAGE_LONGTEXT N_("In Volts [0, 13=vertical, 18=horizontal]")
#define TONE_TEXT N_("22 kHz tone")
#define TONE_LONGTEXT N_("[0=off, 1=on, -1=auto]")
#define FEC_TEXT N_("Transponder FEC")
#define FEC_LONGTEXT N_("FEC=Forward Error Correction mode [9=auto]")
#define SRATE_TEXT N_("Transponder symbol rate in kHz")
#define SRATE_LONGTEXT ""
/* Cable */
#define MODULATION_TEXT N_("Modulation type")
#define MODULATION_LONGTEXT N_("Modulation type for front-end device.")
/* Terrestrial */
#define CODE_RATE_HP_TEXT N_("Terrestrial high priority stream code rate (FEC)")
#define CODE_RATE_HP_LONGTEXT ""
#define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
#define CODE_RATE_LP_LONGTEXT ""
#define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
#define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
#define GUARD_TEXT N_("Terrestrial guard interval")
#define GUARD_LONGTEXT ""
#define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
#define TRANSMISSION_LONGTEXT ""
#define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
#define HIERARCHY_LONGTEXT ""
vlc_module_begin();
set_description( N_("DVB input with v4l2 support") );
add_integer( "dvb-program", 0, NULL, PROGRAM_TEXT, PROGRAM_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-inversion", 2, NULL, INVERSION_TEXT, INVERSION_LONGTEXT,
VLC_TRUE );
add_bool( "dvb-probe", 1, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_TRUE );
add_integer( "dvb-lnb-lof1", 9750000, NULL, LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT,
VLC_TRUE );
add_integer( "dvb-lnb-lof2", 10600000, NULL, LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT,
VLC_TRUE );
add_integer( "dvb-lnb-slof", 11700000, NULL, LNB_SLOF_TEXT,
LNB_SLOF_LONGTEXT, VLC_TRUE );
/* DVB-S (satellite) */
add_bool( "dvb-budget-mode", 0, NULL, BUDGET_TEXT, BUDGET_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-satno", 0, NULL, SATNO_TEXT, SATNO_LONGTEXT,
VLC_TRUE );
add_integer( "dvb-voltage", 13, NULL, VOLTAGE_TEXT, VOLTAGE_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-tone", -1, NULL, TONE_TEXT, TONE_LONGTEXT,
VLC_FALSE );
add_integer( "dvb-fec", 9, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_TRUE );
add_integer( "dvb-srate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT,
VLC_FALSE );
/* DVB-T (terrestrial) */
add_integer( "dvb-modulation", 0, NULL, MODULATION_TEXT, MODULATION_LONGTEXT,
VLC_TRUE );
/* DVB-T (terrestrial) */
add_integer( "dvb-code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT,
CODE_RATE_HP_LONGTEXT, VLC_TRUE );
add_integer( "dvb-code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT,
CODE_RATE_LP_LONGTEXT, VLC_TRUE );
add_integer( "dvb-bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
VLC_TRUE );
add_integer( "dvb-guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, VLC_TRUE );
add_integer( "dvb-transmission", 0, NULL, TRANSMISSION_TEXT,
TRANSMISSION_LONGTEXT, VLC_TRUE );
add_integer( "dvb-hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
VLC_TRUE );
set_capability( "access", 0 );
add_shortcut( "dvb" );
add_shortcut( "dvb-s" );
add_shortcut( "qpsk" );
add_shortcut( "dvb-c" );
add_shortcut( "cable" );
add_shortcut( "dvb-t" );
add_shortcut( "terrestrial" );
add_shortcut( "satellite" ); /* compatibility with the interface. */
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Open: open the frontend device
*****************************************************************************/
int E_(Open) ( vlc_object_t *p_this )
#define GET_OPTION_INT( option ) \
if ( !strncmp( psz_parser, option "=", strlen(option "=") ) ) \
{ \
val.i_int = strtol( psz_parser + strlen(option "="), &psz_parser, \
0 ); \
var_Set( p_input, "dvb-" option, val ); \
}
#define GET_OPTION_BOOL( option ) \
if ( !strncmp( psz_parser, option "=", strlen(option "=") ) ) \
{ \
val.b_bool = strtol( psz_parser + strlen(option "="), &psz_parser, \
0 ); \
var_Set( p_input, "dvb-" option, val ); \
}
static int Open( vlc_object_t *p_this )
{
struct dvb_frontend_info frontend_info;
struct dvb_frontend_parameters fep;
input_thread_t * p_input = (input_thread_t *)p_this;
input_dvb_t * p_dvb;
input_thread_t * p_input = (input_thread_t *)p_this;
thread_dvb_data_t * p_dvb;
char * psz_parser;
char * psz_next;
int i_fd = 0;
char dvr[] = DVR;
char frontend[] = FRONTEND;
int i_len = 0;
vlc_value_t val;
int i_test;
int i_ret;
/* parse the options passed in command line : */
psz_parser = strdup( p_input->psz_name );
if( !psz_parser )
/* Initialize structure */
p_dvb = malloc( sizeof( thread_dvb_data_t ) );
if( p_dvb == NULL )
{
return( -1 );
msg_Err( p_input, "out of memory" );
return -1;
}
memset( p_dvb, 0, sizeof(thread_dvb_data_t) );
p_input->p_access_data = (void *)p_dvb;
msg_Dbg(p_input, "method of access is %s", p_input->psz_access);
/* Register callback functions */
p_input->pf_read = Read;
p_input->pf_set_program = SetProgram;
p_input->pf_set_area = SetArea;
p_input->pf_seek = Seek;
/* Initialise structure */
p_dvb = malloc( sizeof( input_dvb_t ) );
/* Parse the options passed in command line */
if( p_dvb == NULL )
psz_parser = strdup( p_input->psz_name );
if ( !psz_parser )
{
msg_Err( p_input, "out of memory" );
return -1;
free( p_dvb );
return( -1 );
}
p_input->p_access_data = (void *) p_dvb;
/* Get adapter and device number to use for this dvb card */
p_dvb->u_adapter = config_GetInt( p_input, "adapter" );
p_dvb->u_device = config_GetInt( p_input, "device" );
p_dvb->b_probe = config_GetInt( p_input, "probe" );
/* Get antenna configuration options */
p_dvb->b_diseqc = config_GetInt( p_input, "diseqc" );
p_dvb->u_lnb_lof1 = config_GetInt( p_input, "lnb-lof1" );
p_dvb->u_lnb_lof2 = config_GetInt( p_input, "lnb-lof2" );
p_dvb->u_lnb_slof = config_GetInt( p_input, "lnb-slof" );
/* Get modulation parameters */
p_dvb->i_bandwidth = config_GetInt( p_input, "bandwidth");
p_dvb->i_code_rate_HP = config_GetInt(p_input, "code-rate-hp");
p_dvb->i_code_rate_LP = config_GetInt(p_input, "code-rate-lp");
p_dvb->i_modulation = config_GetInt(p_input, "modulation");
p_dvb->i_transmission = config_GetInt(p_input, "transmission");
p_dvb->i_guard = config_GetInt(p_input, "guard");
p_dvb->i_hierarchy = config_GetInt(p_input, "hierarchy");
/* Register Callback functions */
p_input->pf_read = SatelliteRead;
p_input->pf_set_program = SatelliteSetProgram;
p_input->pf_set_area = SatelliteSetArea;
p_input->pf_seek = SatelliteSeek;
/* Parse commandline */
var_Create( p_input, "dvb-program", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-adapter", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-device", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-frequency", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-inversion", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-probe", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-lnb-lof1", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-lnb-lof2", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-lnb-slof", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-budget-mode", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-satno", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-voltage", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-tone", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-fec", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-srate", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-modulation", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-code-rate-hp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-code-rate-lp", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-bandwidth", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-transmission", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-guard", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "dvb-hierarchy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
i_test = strtol( psz_parser, &psz_next, 10 );
if( psz_next == psz_parser )
if ( psz_next == psz_parser )
{
for ( ;; )
for ( ; ; )
{
if( !strncmp( psz_parser, "frequency=",
strlen( "frequency=" ) ) )
GET_OPTION_INT("adapter")
else GET_OPTION_INT("device")
else GET_OPTION_INT("frequency")
else GET_OPTION_INT("inversion")
else GET_OPTION_BOOL("probe")
else GET_OPTION_INT("lnb-lof1")
else GET_OPTION_INT("lnb-lof2")
else GET_OPTION_INT("lnb-slof")
else GET_OPTION_BOOL("budget-mode")
else GET_OPTION_INT("voltage")
else GET_OPTION_INT("tone")
else GET_OPTION_INT("fec")
else GET_OPTION_INT("srate")
else GET_OPTION_INT("modulation")
else GET_OPTION_INT("code-rate-hp")
else GET_OPTION_INT("code-rate-lp")
else GET_OPTION_INT("bandwidth")
else GET_OPTION_INT("transmission")
else GET_OPTION_INT("guard")
else GET_OPTION_INT("hierarchy")
else if( !strncmp( psz_parser, "satno=",
strlen( "satno=" ) ) )
{
p_dvb->u_freq =
(unsigned int)strtol( psz_parser + strlen( "frequency=" ),
&psz_parser, 0 );
psz_parser += strlen( "satno=" );
if ( *psz_parser == 'A' || *psz_parser == 'a' )
val.i_int = -1;
else if ( *psz_parser == 'B' || *psz_parser == 'b' )
val.i_int = -2;
else
val.i_int = strtol( psz_parser, &psz_parser, 0 );
var_Set( p_input, "dvb-satno", val );
}
/* Redundant with voltage but much easier to use */
else if( !strncmp( psz_parser, "polarization=",
strlen( "polarization=" ) ) )
{
char *psz_parser_init;
psz_parser += strlen( "polarization=" );
psz_parser_init = psz_parser;
while ( *psz_parser != ':')
if ( *psz_parser == 'V' || *psz_parser == 'v' )
val.i_int = 13;
else if ( *psz_parser == 'H' || *psz_parser == 'h' )
val.i_int = 18;
else
{
psz_parser++;
}
if( (!strncmp( psz_parser_init, "V" ,
psz_parser - psz_parser_init ) ) ||
(!strncmp( psz_parser_init, "V" ,
psz_parser - psz_parser_init ) ) )
{
p_dvb->i_polarisation = 0;
}
else if( (!strncmp( psz_parser_init, "H" ,
psz_parser - psz_parser_init ) ) ||
(!strncmp( psz_parser_init, "h" ,
psz_parser - psz_parser_init ) ) )
{
p_dvb->i_polarisation = 1;
}
else if( (!strncmp( psz_parser_init, "A" ,
psz_parser - psz_parser_init ) ) ||
(!strncmp( psz_parser_init, "a" ,
psz_parser - psz_parser_init ) ) )
{
p_dvb->i_polarisation = 2;
msg_Err( p_input, "illegal polarization %c", *psz_parser );
free( p_dvb );
return -1;
}
var_Set( p_input, "dvb-voltage", val );
}
else if( !strncmp( psz_parser, "fec=",
strlen( "fec=" ) ) )
{
p_dvb->i_fec =
(int)strtol( psz_parser + strlen( "fec=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "srate=",
strlen( "srate=" ) ) )
{
p_dvb->u_srate =
(unsigned int)strtol( psz_parser + strlen( "srate=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "program=",
strlen( "program=" ) ) )
{
val.i_int = (int)strtol( psz_parser + strlen( "program=" ),
&psz_parser, 0 );
var_Set( p_input, "program", val );
}
else if( !strncmp( psz_parser, "diseqc",
strlen( "disecq" ) ) )
{
psz_parser += strlen("disecq");
p_dvb->b_diseqc = VLC_TRUE;
}
else if( !strncmp( psz_parser, "lnb-lof1=",
strlen( "lnb-lof1=" ) ) )
{
p_dvb->u_lnb_lof1 =
(unsigned int)strtol( psz_parser + strlen( "lnb-lof1=" ),
&psz_parser, 0 );
frontend_info.frequency_min = p_dvb->u_lnb_lof1; /* lnb_lof1 */
}
else if( !strncmp( psz_parser, "lnb-lof2=",
strlen( "lnb-lof2=" ) ) )
{
p_dvb->u_lnb_lof2 =
(unsigned int)strtol( psz_parser + strlen( "lnb-lof2=" ),
&psz_parser, 0 );
frontend_info.frequency_max = p_dvb->u_lnb_lof2; /* in KHz, lnb_lof2 */
}
else if( !strncmp( psz_parser, "lnb-slof=",
strlen( "lnb-slof=" ) ) )
{
p_dvb->u_lnb_slof =
(unsigned int)strtol( psz_parser + strlen( "lnb-slof=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "device=",
strlen( "device=" ) ) )
{
p_dvb->u_device =
(unsigned int)strtol( psz_parser + strlen( "device=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "adapter=",
strlen( "adapter=" ) ) )
{
p_dvb->u_adapter =
(unsigned int)strtol( psz_parser + strlen( "adapter=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "modulation=",
strlen( "modulation=" ) ) )
{
p_dvb->i_modulation = (int)strtol( psz_parser + strlen( "modulation=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "bandwidth=",
strlen( "bandwidth=" ) ) )
{
p_dvb->i_bandwidth = (int)strtol( psz_parser + strlen( "bandwidth=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "guard=",
strlen( "guard=" ) ) )
{
p_dvb->i_guard = (int)strtol( psz_parser + strlen( "guard=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "transmission=",
strlen( "transmission=" ) ) )
{
p_dvb->i_transmission = (int)strtol( psz_parser +
strlen( "transmission=" ),&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "hierarchy=",
strlen( "hierarchy=" ) ) )
{
p_dvb->i_hierarchy = (int)strtol( psz_parser +
strlen( "hierarchy=" ),&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "code-rate-HP=",
strlen( "code-rate-HP=" ) ) )
{
p_dvb->i_code_rate_HP = (int)strtol( psz_parser +
strlen( "code-rate-HP=" ),&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "code-rate-LP=",
strlen( "code-rate-LP=" ) ) )
{
p_dvb->i_code_rate_LP = (int)strtol( psz_parser +
strlen( "code-rate-LP=" ),&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "probe",
strlen( "probe" ) ) )
{
psz_parser += strlen("probe");
p_dvb->b_probe = VLC_TRUE;
}
if( *psz_parser )
if ( *psz_parser )
psz_parser++;
else
break;
......@@ -298,308 +345,60 @@ int E_(Open) ( vlc_object_t *p_this )
}
else
{
msg_Err(p_input, "DVB Input old syntax deprecreated");
msg_Err( p_input, "the DVB input old syntax is deprecated, use vlc " \
"-p dvb to see an explanation of the new syntax" );
free( p_dvb );
return -1;
}
/* Determine frontend device */
i_len = sizeof(FRONTEND);
if( snprintf( frontend, sizeof(FRONTEND), FRONTEND, p_dvb->u_adapter, p_dvb->u_device ) >= i_len )
{
msg_Err( p_input, "snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0';
}
msg_Dbg( p_input, "Opening device %s", frontend );
if( ( p_dvb->i_frontend = open( frontend, O_RDWR )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "Opening device failed (%s)", strerror( errno ));
# else
msg_Err( p_input, "Opening device failed");
# endif
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
/* Determine frontend device information and capabilities */
if( p_dvb->b_probe )
{
if( ioctl_InfoFrontend(p_input, &frontend_info) < 0 )
{
msg_Err( p_input, "(access) cannot determine frontend info" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
}
else /* no frontend probing is done so use default border values. */
{
msg_Dbg( p_input, "using default values for frontend info" );
strncpy(frontend_info.name, frontend, 128);
frontend_info.type = FE_QPSK;
if( (strncmp( p_input->psz_access, "qpsk", 4) ==0) ||
(strncmp( p_input->psz_access, "dvb-s", 5 ) == 0) ||
(strncmp( p_input->psz_access, "satellite", 9 ) == 0) )
frontend_info.type = FE_QPSK;
else if( (strncmp( p_input->psz_access, "cable", 5) ==0) ||
(strncmp( p_input->psz_access, "dvb-c", 5 ) == 0) )
frontend_info.type = FE_QAM;
else if( (strncmp( p_input->psz_access, "terrestrial", 11) ==0) ||
(strncmp( p_input->psz_access, "dvb-t", 5 ) == 0) )
frontend_info.type = FE_OFDM;
frontend_info.frequency_max = p_dvb->u_lnb_lof2; /* in KHz, lnb_lof2 */
frontend_info.frequency_min = p_dvb->u_lnb_lof1; /* lnb_lof1 */
frontend_info.symbol_rate_max = 30000000;
frontend_info.symbol_rate_min = 1000000;
}
/* Sanity check */
if( ((strncmp( p_input->psz_access, "qpsk", 4 ) == 0) ||
(strncmp( p_input->psz_access, "dvb-s", 5 ) == 0) ||
(strncmp( p_input->psz_access, "satellite", 9 ) == 0) ) &&
(frontend_info.type != FE_QPSK) )
{
if( frontend_info.type == FE_OFDM )
msg_Err(p_input, "User expects DVB-S card but DVB-T card found.");
else if( frontend_info.type == FE_QAM )
msg_Err(p_input, "User expects DVB-S card but DVB-C card found.");
else msg_Err(p_input, "User expects DVB-S card but unknown card found.");
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
if( ((strncmp( p_input->psz_access, "cable", 5 ) == 0) ||
(strncmp( p_input->psz_access, "dvb-c", 5 ) == 0) ) &&
(frontend_info.type != FE_QAM) )
/* Getting frontend info */
if ( E_(FrontendOpen)( p_input ) < 0 )
{
if( frontend_info.type == FE_OFDM )
msg_Err( p_input, "User expects DVB-C card but DVB-T card found." );
else if( frontend_info.type == FE_QPSK )
msg_Err( p_input, "User expects DVB-C card but DVB-S card found." );
else msg_Err( p_input, "User expects DVB-C card but unknown card found." );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
if( ((strncmp( p_input->psz_access, "terrestrial", 11 ) == 0) ||
(strncmp( p_input->psz_access, "dvb-t", 5 ) == 0) ) &&
(frontend_info.type != FE_OFDM) )
{
if( frontend_info.type == FE_QAM )
msg_Err(p_input, "User expects DVB-T card but DVB-C card found.");
else if( frontend_info.type == FE_QPSK )
msg_Err(p_input, "User expects DVB-T card but DVB-S card found.");
else msg_Err(p_input, "User expects DVB-T card but unknown card found.");
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
#if 0
/* Validating input values (QPSK in KHz, OFDM/QAM in Hz) */
if( ((p_dvb->u_freq) > frontend_info.frequency_max) ||
((p_dvb->u_freq) < frontend_info.frequency_min) )
/* Setting frontend parameters for tuning the hardware */
msg_Dbg( p_input, "trying to tune the frontend...");
if ( E_(FrontendSet)( p_input ) < 0 )
{
if( (p_dvb->u_freq) > frontend_info.frequency_max )
msg_Err( p_input, "given frequency %u (kHz) > %u (kHz) max. frequency",
p_dvb->u_freq, frontend_info.frequency_max );
else
msg_Err( p_input, "given frequency %u (kHz) < %u (kHz) min.frequency",
p_dvb->u_freq, frontend_info.frequency_min );
msg_Err( p_input, "bailing out given frequency outside specification range for this frontend" );
close( p_dvb->i_frontend );
E_(FrontendClose)( p_input );
free( p_dvb );
return -1;
}
#endif
/* Workaround for backwards compatibility */
if( strncmp( p_input->psz_access, "satellite", 9 ) ==0 )
{
msg_Warn( p_input, "invalid symbol rate %d possibly specified in MHz, trying value *1000 KHz", p_dvb->u_srate );
p_dvb->u_srate *= 1000UL;
}
if( ((p_dvb->u_srate) > frontend_info.symbol_rate_max) ||
((p_dvb->u_srate) < frontend_info.symbol_rate_min) )
{
msg_Warn( p_input, "invalid symbol rate, using default one" );
p_dvb->u_srate = config_GetInt( p_input, "symbol-rate" );
if( ((p_dvb->u_srate) > frontend_info.symbol_rate_max) ||
((p_dvb->u_srate) < frontend_info.symbol_rate_min) )
{
msg_Err( p_input, "invalid default symbol rate" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
}
if( (p_dvb->i_fec > 9) || (p_dvb->i_fec < 1) )
{
msg_Warn( p_input, "invalid FEC, using default one" );
p_dvb->i_fec = config_GetInt( p_input, "fec" );
if( (p_dvb->i_fec > 9) || (p_dvb->i_fec < 1) )
{
msg_Err( p_input, "invalid default FEC" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
}
/* Setting frontend parameters for tuning the hardware */
msg_Dbg( p_input, "Trying to tune to channel ...");
switch( frontend_info.type )
{
/* DVB-S: satellite and budget cards (nova) */
case FE_QPSK:
fep.frequency = p_dvb->u_freq; /* KHz */
fep.inversion = dvb_DecodeInversion( p_input, p_dvb->i_polarisation );
fep.u.qpsk.symbol_rate = p_dvb->u_srate;
fep.u.qpsk.fec_inner = dvb_DecodeFEC( p_input, p_dvb->i_fec );
msg_Dbg( p_input, "DVB-S: satellite (QPSK) frontend %s found", frontend_info.name );
while( (i_ret = ioctl_SetQPSKFrontend( p_input, fep )) < 0 )
{
if( (i_ret != -3) && (i_ret < 0))
{
msg_Err( p_input, "DVB-S: tuning failed" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
}
break;
/* DVB-C */
case FE_QAM:
fep.frequency = p_dvb->u_freq; /* in Hz */
fep.inversion = dvb_DecodeInversion( p_input, p_dvb->i_polarisation );
fep.u.qam.symbol_rate = p_dvb->u_srate;
fep.u.qam.fec_inner = dvb_DecodeFEC( p_input, p_dvb->i_fec );
fep.u.qam.modulation = dvb_DecodeModulation( p_input, p_dvb->i_modulation );
msg_Dbg( p_input, "DVB-C: cable (QAM) frontend %s found", frontend_info.name );
while( ( i_ret = ioctl_SetQAMFrontend( p_input, fep ) ) < 0 )
{
if( (i_ret != -3) && (i_ret < 0))
{
msg_Err( p_input, "DVB-C: tuning failed" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
}
break;
/* DVB-T */
case FE_OFDM:
fep.frequency = p_dvb->u_freq; /* in Hz */
fep.inversion = dvb_DecodeInversion( p_input, p_dvb->i_polarisation );
fep.u.ofdm.bandwidth = dvb_DecodeBandwidth( p_input, p_dvb->i_bandwidth );
fep.u.ofdm.code_rate_HP = dvb_DecodeFEC( p_input, p_dvb->i_code_rate_HP );
fep.u.ofdm.code_rate_LP = dvb_DecodeFEC( p_input, p_dvb->i_code_rate_LP );
fep.u.ofdm.constellation = dvb_DecodeModulation( p_input, p_dvb->i_modulation );
fep.u.ofdm.transmission_mode = dvb_DecodeTransmission( p_input, p_dvb->i_transmission );
fep.u.ofdm.guard_interval = dvb_DecodeGuardInterval( p_input, p_dvb->i_guard );
fep.u.ofdm.hierarchy_information = dvb_DecodeHierarchy( p_input, p_dvb->i_hierarchy );
msg_Dbg( p_input, "DVB-T: terrestrial (OFDM) frontend %s found", frontend_info.name );
while( (i_ret=ioctl_SetOFDMFrontend( p_input, fep )) < 0 )
{
if( (i_ret != -3) && (i_ret < 0))
{
msg_Err( p_input, "DVB-T: tuning failed" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
}
break;
default:
msg_Err( p_input, "Could not determine frontend type on %s", frontend_info.name );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
msg_Dbg( p_input, "Tuning done.");
/* Initialise structure */
p_dvb->p_satellite = malloc( sizeof( input_socket_t ) );
if( p_dvb->p_satellite == NULL )
/* Opening DVR device */
if ( E_(DVROpen)( p_input ) < 0 )
{
msg_Err( p_input, "out of memory" );
close( p_dvb->i_frontend );
E_(FrontendClose)( p_input );
free( p_dvb );
return -1;
}
/* Open the DVR device */
i_len = sizeof(DVR);
if( snprintf( dvr, sizeof(DVR), DVR, p_dvb->u_adapter, p_dvb->u_device ) >= i_len )
{
msg_Err( p_input, "snprintf() truncated string for DVR" );
dvr[sizeof(DVR)] = '\0';
}
msg_Dbg( p_input, "opening DVR device '%s'", dvr );
if( (p_dvb->p_satellite->i_handle = open( dvr,
/*O_NONBLOCK | O_LARGEFILE*/0 ) ) == (-1) )
var_Get( p_input, "dvb-budget-mode", &val );
p_dvb->b_budget_mode = val.b_bool;
if ( val.b_bool )
{
# ifdef HAVE_ERRNO_H
msg_Warn( p_input, "cannot open `%s' (%s)", dvr, strerror( errno ) );
# else
msg_Warn( p_input, "cannot open `%s'", dvr );
# endif
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
msg_Dbg( p_input, "setting filter on all PIDs" );
AllocateDemux( p_input, 0x2000, OTHER_TYPE );
}
msg_Dbg( p_input, "setting filter on PAT" );
/* Set Filter on PAT packet */
if( ioctl_SetDMXFilter(p_input, 0, &i_fd, 21 ) < 0 )
else
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "an error occured when setting filter on PAT (%s)", strerror( errno ) );
# else
msg_Err( p_input, "an error occured when setting filter on PAT" );
# endif
close( p_dvb->p_satellite->i_handle );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
msg_Dbg( p_input, "setting filter on PAT" );
AllocateDemux( p_input, 0x0, OTHER_TYPE );
}
if( input_InitStream( p_input, sizeof( stream_ts_data_t ) ) == -1 )
{
msg_Err( p_input, "could not initialize stream structure" );
close( p_dvb->p_satellite->i_handle );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
close( p_dvb->i_handle );
free( p_dvb );
return( -1 );
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = 1;
p_input->stream.b_pace_control = 0;
p_input->stream.b_seekable = 0;
p_input->stream.p_selected_area->i_tell = 0;
......@@ -614,142 +413,199 @@ int E_(Open) ( vlc_object_t *p_this )
/*****************************************************************************
* Close : Close the device
*****************************************************************************/
void E_(Close) ( vlc_object_t *p_this )
static void Close( vlc_object_t *p_this )
{
input_thread_t * p_input = (input_thread_t *)p_this;
input_dvb_t * p_dvb;
unsigned int i_es_index;
if( p_input->stream.p_selected_program )
thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
if ( !p_dvb->b_budget_mode )
{
CloseProgram( p_input );
}
if ( p_dvb->p_demux_handles[0].i_type )
{
E_(DMXUnsetFilter)( p_input, p_dvb->p_demux_handles[0].i_handle );
p_dvb->p_demux_handles[0].i_type = 0;
}
}
/*****************************************************************************
* Read: reads data from the satellite card
*****************************************************************************/
static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len )
{
thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
ssize_t i_ret;
vlc_value_t val;
struct timeval timeout;
fd_set fds;
if ( !p_dvb->b_budget_mode && !p_dvb->p_demux_handles[1].i_type )
{
for( i_es_index = 1 ;
i_es_index < p_input->stream.p_selected_program->i_es_number;
i_es_index ++ )
int i_program;
unsigned int i;
var_Get( p_input, "dvb-program", &val );
i_program = val.i_int;
/* FIXME : this is not demux2-compatible */
for ( i = 0; i < p_input->stream.i_pgrm_number; i++ )
{
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
if( p_es->p_dec )
/* Only set a filter on the selected program : some boards
* (read: Dreambox) only have 8 filters, so you don't want to
* spend them on unwanted PMTs. --Meuuh */
msg_Err(p_input, "Meuuh %d %d %d", p_input->stream.pp_programs[i]->i_number, p_input->stream.pp_programs[i]->pp_es[0]->i_id, i_program);
if ( !i_program
|| p_input->stream.pp_programs[i]->i_number == i_program )
{
ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd );
msg_Dbg( p_input, "setting filter on PMT pid %d",
p_input->stream.pp_programs[i]->pp_es[0]->i_id );
AllocateDemux( p_input,
p_input->stream.pp_programs[i]->pp_es[0]->i_id,
OTHER_TYPE );
}
#undef p_es
}
}
p_dvb = (input_dvb_t *)p_input->p_access_data;
/* Find if some data is available. This won't work under Windows. */
close( p_dvb->p_satellite->i_handle );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
}
/* Initialize file descriptor set */
FD_ZERO( &fds );
FD_SET( p_dvb->i_handle, &fds );
/*****************************************************************************
* SatelliteRead: reads data from the satellite card
*****************************************************************************/
static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len )
{
input_dvb_t * p_dvb = (input_dvb_t *)p_input->p_access_data;
ssize_t i_ret;
unsigned int i;
/* We'll wait 0.5 second if nothing happens */
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
/* if not set, set filters to the PMTs */
for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
/* Find if some data is available */
while ( (i_ret = select( p_dvb->i_handle + 1, &fds,
NULL, NULL, &timeout )) == 0
|| (i_ret < 0 && errno == EINTR) )
{
if( p_input->stream.pp_programs[i]->pp_es[0]->i_demux_fd == 0 )
FD_ZERO( &fds );
FD_SET( p_dvb->i_handle, &fds );
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
if ( p_input->b_die || p_input->b_error )
{
ioctl_SetDMXFilter( p_input, p_input->stream.pp_programs[i]->pp_es[0]->i_id,
&p_input->stream.pp_programs[i]->pp_es[0]->i_demux_fd, 21 );
return 0;
}
}
i_ret = read( p_dvb->p_satellite->i_handle, p_buffer, i_len );
if ( i_ret < 0 )
{
#ifdef HAVE_ERRNO_H
msg_Err( p_input, "select error (%s)", strerror(errno) );
#else
msg_Err( p_input, "select error" );
#endif
return -1;
}
i_ret = read( p_dvb->i_handle, p_buffer, i_len );
if( i_ret < 0 )
{
# ifdef HAVE_ERRNO_H
#ifdef HAVE_ERRNO_H
msg_Err( p_input, "read failed (%s)", strerror(errno) );
# else
#else
msg_Err( p_input, "read failed" );
# endif
#endif
}
return i_ret;
}
/*****************************************************************************
* SatelliteSetArea : Does nothing
* SetArea : Does nothing
*****************************************************************************/
static int SatelliteSetArea( input_thread_t * p_input, input_area_t * p_area )
static int SetArea( input_thread_t * p_input, input_area_t * p_area )
{
return -1;
}
/*****************************************************************************
* SatelliteSetProgram : Sets the card filters according to the
* selected program,
* and makes the appropriate changes to stream structure.
* SetProgram : Sets the card filters according to the selected program,
* and makes the appropriate changes to stream structure.
*****************************************************************************/
int SatelliteSetProgram( input_thread_t * p_input,
pgrm_descriptor_t * p_new_prg )
static int SetProgram( input_thread_t * p_input,
pgrm_descriptor_t * p_new_prg )
{
input_dvb_t * p_dvb = (input_dvb_t *)p_input->p_access_data;
thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
unsigned int i_es_index;
vlc_value_t val;
unsigned int u_video_type = 1; /* default video type */
unsigned int u_audio_type = 2; /* default audio type */
int i_video_type = VIDEO0_TYPE;
int i_audio_type = AUDIO0_TYPE;
if( p_input->stream.p_selected_program )
if ( p_input->stream.p_selected_program )
{
for( i_es_index = 1 ; /* 0 should be the PMT */
i_es_index < p_input->stream.p_selected_program->i_es_number ;
for ( i_es_index = 0; /* 0 should be the PMT */
i_es_index < p_input->stream.p_selected_program->i_es_number;
i_es_index ++ )
{
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
if( p_es->p_dec )
if ( p_es->p_dec )
{
input_UnselectES( p_input , p_es );
}
if( p_es->i_demux_fd > 0 )
{
ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd );
p_es->i_demux_fd = 0;
}
#undef p_es
}
}
for (i_es_index = 1 ; i_es_index < p_new_prg->i_es_number ; i_es_index ++ )
if ( !p_dvb->b_budget_mode )
{
msg_Dbg( p_input, "unsetting filters on all pids" );
CloseProgram( p_input );
msg_Dbg( p_input, "setting filter on PMT pid %d",
p_new_prg->pp_es[0]->i_id );
AllocateDemux( p_input, p_new_prg->pp_es[0]->i_id, OTHER_TYPE );
}
for ( i_es_index = 1; i_es_index < p_new_prg->i_es_number;
i_es_index++ )
{
#define p_es p_new_prg->pp_es[i_es_index]
switch( p_es->i_cat )
{
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
case MPEG2_MOTO_VIDEO_ES:
if( input_SelectES( p_input , p_es ) == 0 )
{
ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, u_video_type);
u_video_type += 5;
}
break;
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
if( input_SelectES( p_input , p_es ) == 0 )
{
ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, u_audio_type);
input_SelectES( p_input , p_es );
u_audio_type += 5;
}
break;
default:
ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, 21);
input_SelectES( p_input , p_es );
msg_Warn(p_input, "ES streamtype 0x%d found used as DMX_PES_OTHER !!",(int) p_es->i_cat);
break;
#undef p_es
case VIDEO_ES:
if ( !p_dvb->b_budget_mode )
{
msg_Dbg(p_input, "setting filter on video ES 0x%x",
p_es->i_id);
/* Always set the filter. This may seem a little odd, but
* it allows you to stream the video with demuxstream
* without having a decoder or a stream output behind.
* The result is you'll sometimes filter a PID which you
* don't really want, but in the most common cases it
* should be OK. --Meuuh */
AllocateDemux( p_input, p_es->i_id, i_video_type );
i_video_type += TYPE_INTERVAL;
}
input_SelectES( p_input, p_es );
break;
case AUDIO_ES:
if ( !p_dvb->b_budget_mode )
{
msg_Dbg(p_input, "setting filter on audio ES 0x%x",
p_es->i_id);
AllocateDemux( p_input, p_es->i_id, i_audio_type );
i_audio_type += TYPE_INTERVAL;
}
input_SelectES( p_input, p_es );
break;
default:
if ( !p_dvb->b_budget_mode )
{
msg_Dbg(p_input, "setting filter on other ES 0x%x",
p_es->i_id);
AllocateDemux( p_input, p_es->i_id, OTHER_TYPE );
}
input_SelectES( p_input, p_es );
break;
}
#undef p_es
}
p_input->stream.p_selected_program = p_new_prg;
......@@ -762,10 +618,56 @@ int SatelliteSetProgram( input_thread_t * p_input,
}
/*****************************************************************************
* SatelliteSeek: does nothing (not a seekable stream
* Seek: does nothing (not a seekable stream
*****************************************************************************/
static void SatelliteSeek( input_thread_t * p_input, off_t i_off )
static void Seek( input_thread_t * p_input, off_t i_off )
{
;
}
/*****************************************************************************
* AllocateDemux:
*****************************************************************************/
static void AllocateDemux( input_thread_t * p_input, int i_pid,
int i_type )
{
thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
int i;
/* Find first free slot */
for ( i = 0; i < MAX_DEMUX; i++ )
{
if ( !p_dvb->p_demux_handles[i].i_type )
{
if ( E_(DMXSetFilter)( p_input, i_pid,
&p_dvb->p_demux_handles[i].i_handle,
i_type ) < 0 )
{
break;
}
p_dvb->p_demux_handles[i].i_type = i_type;
p_dvb->p_demux_handles[i].i_pid = i_pid;
break;
}
}
}
/*****************************************************************************
* CloseProgram:
*****************************************************************************/
static void CloseProgram( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb = (thread_dvb_data_t *)p_input->p_access_data;
int i;
for ( i = 1; i < MAX_DEMUX; i++ )
{
if ( p_dvb->p_demux_handles[i].i_type )
{
E_(DMXUnsetFilter)( p_input, p_dvb->p_demux_handles[i].i_handle );
p_dvb->p_demux_handles[i].i_type = 0;
}
}
}
/*****************************************************************************
* dvb.c : functions to control a DVB card under Linux with v4l2
*****************************************************************************
* Copyright (C) 1998-2003 VideoLAN
*
* Authors: Damien Lucas <nitrox@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@wxs.nl>
* Christopher Ross <chris@tebibyte.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <sys/ioctl.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
# include <string.h>
# include <errno.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
/* DVB Card Drivers */
#include <linux/dvb/version.h>
#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
#include <linux/errno.h>
#include "dvb.h"
struct diseqc_cmd_t
{
struct dvb_diseqc_master_cmd cmd;
uint32_t wait;
};
struct diseqc_cmd_t switch_cmds[] =
{
{ { { 0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf2, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf1, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf3, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf4, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf6, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf5, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf7, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf8, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xfa, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xf9, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xfb, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xfc, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xfe, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xfd, 0x00, 0x00 }, 4 }, 0 },
{ { { 0xe0, 0x10, 0x38, 0xff, 0x00, 0x00 }, 4 }, 0 }
};
static int ioctl_CheckFrontend( input_thread_t * p_input, fe_type_t type );
/*****************************************************************************
* ioctl_InfoFrontend : return information about given frontend
*****************************************************************************/
int ioctl_InfoFrontend( input_thread_t * p_input, struct dvb_frontend_info *info )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
/* Determine type of frontend */
if( (i_ret = ioctl( fd_front, FE_GET_INFO, info )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "Getting info from frontend failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "Getting info from frontend failed (%d)", i_ret );
# endif
return -1;
}
/* Print out frontend capabilities. */
msg_Dbg( p_input, "Frontend Info:" );
msg_Dbg( p_input, " name = %s", info->name );
switch( info->type )
{
case FE_QPSK:
msg_Dbg( p_input, " type = QPSK (DVB-S)" );
break;
case FE_QAM:
msg_Dbg( p_input, " type = QAM (DVB-C)" );
break;
case FE_OFDM:
msg_Dbg( p_input, " type = OFDM (DVB-T)" );
break;
default:
msg_Err( p_input, " unknown frontend found fe_type_t(%d)", info->type );
return -1;
}
msg_Dbg( p_input, " frequency_min = %u (kHz)", info->frequency_min );
msg_Dbg( p_input, " frequency_max = %u (kHz)", info->frequency_max );
msg_Dbg( p_input, " frequency_stepsize = %u", info->frequency_stepsize );
msg_Dbg( p_input, " frequency_tolerance = %u", info->frequency_tolerance );
msg_Dbg( p_input, " symbol_rate_min = %u (kHz)", info->symbol_rate_min );
msg_Dbg( p_input, " symbol_rate_max = %u (kHz)", info->symbol_rate_max );
msg_Dbg( p_input, " symbol_rate_tolerance (ppm) = %u", info->symbol_rate_tolerance );
msg_Dbg( p_input, " notifier_delay (ms)= %u", info->notifier_delay );
msg_Dbg( p_input, "Frontend Info capability list:" );
if( info->caps & FE_IS_STUPID )
msg_Dbg( p_input, " no capabilities - frontend is stupid!" );
if( info->caps & FE_CAN_INVERSION_AUTO )
msg_Dbg( p_input, " inversion auto" );
if( info->caps & FE_CAN_FEC_1_2 )
msg_Dbg( p_input, " forward error correction 1/2" );
if( info->caps & FE_CAN_FEC_2_3 )
msg_Dbg( p_input, " forward error correction 2/3" );
if( info->caps & FE_CAN_FEC_3_4 )
msg_Dbg( p_input, " forward error correction 3/4" );
if( info->caps & FE_CAN_FEC_4_5 )
msg_Dbg( p_input, " forward error correction 4/5" );
if( info->caps & FE_CAN_FEC_5_6 )
msg_Dbg( p_input, " forward error correction 5/6" );
if( info->caps & FE_CAN_FEC_6_7 )
msg_Dbg( p_input, " forward error correction 6/7" );
if( info->caps & FE_CAN_FEC_7_8 )
msg_Dbg( p_input, " forward error correction 7/8" );
if( info->caps & FE_CAN_FEC_8_9 )
msg_Dbg( p_input, " forward error correction 8/9" );
if( info->caps & FE_CAN_FEC_AUTO )
msg_Dbg( p_input, " forward error correction auto" );
if( info->caps & FE_CAN_QPSK )
msg_Dbg( p_input, " card can do QPSK" );
if( info->caps & FE_CAN_QAM_16 )
msg_Dbg( p_input, " card can do QAM 16" );
if( info->caps & FE_CAN_QAM_32 )
msg_Dbg( p_input, " card can do QAM 32" );
if( info->caps & FE_CAN_QAM_64 )
msg_Dbg( p_input, " card can do QAM 64" );
if( info->caps & FE_CAN_QAM_128 )
msg_Dbg( p_input, " card can do QAM 128" );
if( info->caps & FE_CAN_QAM_256 )
msg_Dbg( p_input, " card can do QAM 256" );
if( info->caps & FE_CAN_QAM_AUTO )
msg_Dbg( p_input, " card can do QAM auto" );
if( info->caps & FE_CAN_TRANSMISSION_MODE_AUTO )
msg_Dbg( p_input, " transmission mode auto" );
if( info->caps & FE_CAN_BANDWIDTH_AUTO )
msg_Dbg(p_input, " bandwidth mode auto" );
if( info->caps & FE_CAN_GUARD_INTERVAL_AUTO )
msg_Dbg( p_input, " guard interval mode auto" );
if( info->caps & FE_CAN_HIERARCHY_AUTO )
msg_Dbg( p_input, " hierarchy mode auto" );
if( info->caps & FE_CAN_MUTE_TS )
msg_Dbg( p_input, " card can mute TS" );
if( info->caps & FE_CAN_CLEAN_SETUP )
msg_Dbg( p_input, " clean setup" );
msg_Dbg( p_input,"End of capability list" );
return 0;
}
/* QPSK only */
int ioctl_DiseqcSendMsg( input_thread_t *p_input, fe_sec_voltage_t v, struct diseqc_cmd_t **cmd,
fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
if( (i_ret = ioctl( fd_front, FE_SET_TONE, SEC_TONE_OFF )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "ioclt FE_SET_TONE failed, tone=%s (%d) %s", SEC_TONE_ON ? "on" : "off", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "ioclt FE_SET_TONE failed, tone=%s (%d)", SEC_TONE_ON ? "on" : "off", i_ret );
# endif
return i_ret;
}
if( (i_ret = ioctl( fd_front, FE_SET_VOLTAGE, v )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d) %s", v, i_ret, strerror( errno ) );
# else
msg_Err( p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d)", v, i_ret );
# endif
return i_ret;
}
msleep( 15 );
while( *cmd )
{
msg_Dbg( p_input, "DiseqcSendMsg(): %02x %02x %02x %02x %02x %02x",
(*cmd)->cmd.msg[0], (*cmd)->cmd.msg[1],
(*cmd)->cmd.msg[2], (*cmd)->cmd.msg[3],
(*cmd)->cmd.msg[4], (*cmd)->cmd.msg[5] );
if( (i_ret = ioctl( fd_front, FE_DISEQC_SEND_MASTER_CMD, &(*cmd)->cmd )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d)", i_ret );
# endif
return i_ret;
}
msleep( (*cmd)->wait );
cmd++;
}
msleep( 15 );
if( (i_ret = ioctl( fd_front, FE_DISEQC_SEND_BURST, b )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d) %s", b, i_ret, strerror( errno ) );
# else
msg_Err( p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d)", b, i_ret );
# endif
return i_ret;
}
msleep( 15 );
if( (i_ret = ioctl( fd_front, FE_SET_TONE, t )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "ioctl FE_SET_TONE failed, tone=%d (%d) %s", t, i_ret, strerror( errno ) );
# else
msg_Err( p_input, "ioctl FE_SET_TONE failed, tone=%d (%d)", t, i_ret );
# endif
return i_ret;
}
return i_ret;
}
/* QPSK only */
int ioctl_SetupSwitch( input_thread_t *p_input, int switch_pos,
int voltage_18, int hiband )
{
struct diseqc_cmd_t *cmd[2] = { NULL, NULL };
int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
int i_ret;
msg_Dbg( p_input, "DVB-S: setup switch pos %i, %sV, %sband, index %i",
switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo", i );
if( (i < 0) || (i >= (int)(sizeof(switch_cmds)/sizeof(struct diseqc_cmd_t))) )
return -EINVAL;
cmd[0] = &switch_cmds[i];
if( (i_ret = ioctl_DiseqcSendMsg (p_input,
(i % 2) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13,
cmd,
(i/2) % 2 ? SEC_TONE_ON : SEC_TONE_OFF,
(i/4) % 2 ? SEC_MINI_B : SEC_MINI_A)) < 0 )
{
return i_ret;
}
return i_ret;
}
/*****************************************************************************
* ioctl_SetQPSKFrontend : controls the FE device
*****************************************************************************/
int ioctl_SetQPSKFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int hiband;
int i_ret;
/* Set the frequency of the transponder, taking into account the
local frequencies of the LNB */
hiband = (fep.frequency >= p_dvb->u_lnb_slof);
if( (i_ret=ioctl_SetupSwitch (p_input, 0, p_dvb->i_polarisation, hiband)) < 0 )
{
msg_Err( p_input, "DVB-S: Setup frontend switch failed (%d)", i_ret );
return -1;
}
if( hiband )
fep.frequency -= p_dvb->u_lnb_lof2;
else
fep.frequency -= p_dvb->u_lnb_lof1;
/* Now send it all to the frontend device */
if( (i_ret=ioctl(fd_front, FE_SET_FRONTEND, &fep)) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "DVB-S: setting frontend failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "DVB-S: setting frontend failed (%d)", i_ret );
# endif
return -1;
}
i_ret = ioctl_CheckFrontend( p_input, FE_QPSK );
return i_ret;
}
int ioctl_SetOFDMFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
/* Now send it all to the frontend device */
if( (i_ret=ioctl(fd_front, FE_SET_FRONTEND, &fep)) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "DVB-T: setting frontend failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "DVB-T: setting frontend failed (%d)", i_ret );
# endif
return -1;
}
i_ret = ioctl_CheckFrontend( p_input, FE_OFDM );
return i_ret;
}
int ioctl_SetQAMFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
/* Show more info on the tuning parameters used. */
msg_Dbg( p_input, "DVB-C: Tuning with the following paramters:" );
msg_Dbg( p_input, "DVB-C: Frequency %d KHz", fep.frequency );
msg_Dbg( p_input, "DVB-C: Inversion/polarisation: %d", fep.inversion );
msg_Dbg( p_input, "DVB-C: Symbolrate %d", fep.u.qam.symbol_rate );
msg_Dbg( p_input, "DVB-C: Forward Error Correction Inner %d", fep.u.qam.fec_inner );
msg_Dbg( p_input, "DVB-C: Modulation %d", fep.u.qam.modulation );
/* Now send it all to the frontend device */
if( (i_ret=ioctl(fd_front, FE_SET_FRONTEND, &fep)) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "DVB-C: tuning channel failed (frontend returned %d:%s)", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "DVB-C: tuning channel failed (frontend returned %d)", i_ret );
# endif
return -1;
}
/* Check Status of frontend */
i_ret = ioctl_CheckFrontend( p_input, FE_QAM );
return i_ret;
}
/******************************************************************
* Check completion of the frontend control sequence
******************************************************************/
static int ioctl_CheckFrontend( input_thread_t * p_input, fe_type_t type )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
while( !p_input->b_die || !p_input->b_error )
{
int32_t value;
fe_status_t status;
if( (i_ret = ioctl( fd_front, FE_READ_STATUS, &status )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "reading frontend status failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err( p_input, "reading frontend status failed (%d)", i_ret );
# endif
return -1;
}
if( status & FE_HAS_SIGNAL ) /* found something above the noise level */
msg_Dbg( p_input, "check frontend ... has signal" );
if( status & FE_HAS_CARRIER ) /* found a DVB signal */
msg_Dbg( p_input, "check frontend ... has carrier" );
if( status & FE_HAS_VITERBI ) /* FEC is stable */
msg_Dbg( p_input, "check frontend ... has stable forward error correction" );
if( status & FE_HAS_SYNC ) /* found sync bytes */
msg_Dbg( p_input, "check frontend ... has sync" );
if( status & FE_HAS_LOCK ) /* everything's working... */
{
msg_Dbg( p_input, "check frontend ... has lock" );
msg_Dbg( p_input, "check frontend ... tuning status == 0x%02x ... tuning succeeded", status );
return 0;
}
if( status & FE_TIMEDOUT ) /* no lock within the last ~2 seconds */
{
msg_Dbg( p_input, "check frontend ... tuning status == 0x%02x ... timed out", status );
msg_Err( p_input, "check frontend ... tuning failed" );
return -2;
}
if( status & FE_REINIT )
{
/* frontend was reinitialized, */
/* application is recommned to reset */
/* DiSEqC, tone and parameters */
switch( type )
{
case FE_OFDM:
msg_Dbg( p_input, "DVB-T: tuning status == 0x%02x", status );
break;
case FE_QPSK:
msg_Dbg( p_input, "DVB-S: tuning status == 0x%02x", status );
break;
case FE_QAM:
msg_Dbg( p_input, "DVB-C: tuning status == 0x%02x", status );
break;
default:
break;
}
msg_Err( p_input, "check frontend ... resend frontend parameters" );
msg_Err( p_input, "check frontend ... tuning failed" );
return -3;
}
/* Read some statistics */
value=0;
if( ioctl( fd_front, FE_READ_BER, &value ) >= 0 )
msg_Dbg( p_input, "Bit error rate: %d", value );
value=0;
if( ioctl( fd_front, FE_READ_SIGNAL_STRENGTH, &value ) >= 0 )
msg_Dbg( p_input,"Signal strength: %d", value );
value=0;
if( ioctl( fd_front, FE_READ_SNR, &value ) >= 0 )
msg_Dbg( p_input, "SNR: %d", value );
usleep( 500000 );
}
return -1;
}
/*****************************************************************************
* ioctl_SetDMXFilter : controls the demux to add a filter
*****************************************************************************/
int ioctl_SetDMXFilter( input_thread_t * p_input, int i_pid, int * pi_fd , int i_type )
{
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
struct dmx_pes_filter_params s_filter_params;
char dmx[] = DMX;
int i_len;
int result;
/* We first open the device */
i_len = sizeof(DMX);
if( snprintf( dmx, sizeof(DMX), DMX, p_dvb->u_adapter, p_dvb->u_device) >= i_len )
{
msg_Err( p_input, "snprintf() truncated string for DMX" );
dmx[sizeof(DMX)] = '\0';
}
msg_Dbg( p_input, "Opening demux device %s", dmx );
if( ( (*pi_fd) = open( dmx, O_RDWR|O_NONBLOCK )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "Demux set filter: opening device failed (%s)", strerror( errno ) );
# else
msg_Err( p_input, "Demux set filter: opening device failed" );
# endif
return -1;
}
/* We fill the DEMUX structure : */
s_filter_params.pid = i_pid;
s_filter_params.input = DMX_IN_FRONTEND;
s_filter_params.output = DMX_OUT_TS_TAP;
switch( i_type )
{ /* First device */
case 1:
msg_Dbg( p_input, "Demux set filter DMX_PES_VIDEO0 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_VIDEO0;
break;
case 2:
msg_Dbg( p_input, "Demux set filter DMX_PES_AUDIO0 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_AUDIO0;
break;
case 3:
msg_Dbg( p_input, "Demux set filter DMX_PES_TELETEXT0 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_TELETEXT0;
break;
case 4:
msg_Dbg( p_input, "Demux set filter DMX_PES_SUBTITLE0 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_SUBTITLE0;
break;
case 5:
msg_Dbg( p_input, "Demux set filter DMX_PES_PCR0 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_PCR0;
break;
/* Second device */
case 6:
msg_Dbg( p_input, "Demux set filter DMX_PES_VIDEO1 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_VIDEO1;
break;
case 7:
msg_Dbg( p_input, "Demux set filter DMX_PES_AUDIO1 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_AUDIO1;
break;
case 8:
msg_Dbg( p_input, "Demux set filter DMX_PES_TELETEXT1 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_TELETEXT1;
break;
case 9:
msg_Dbg( p_input, "Demux set filter DMX_PES_SUBTITLE1 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_SUBTITLE1;
break;
case 10:
msg_Dbg( p_input, "Demux set filter DMX_PES_PCR1 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_PCR1;
break;
/* Third device */
case 11:
msg_Dbg( p_input, "Demux set filter DMX_PES_VIDEO2 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_VIDEO2;
break;
case 12:
msg_Dbg( p_input, "Demux set filter DMX_PES_AUDIO2 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_AUDIO2;
break;
case 13:
msg_Dbg( p_input, "Demux set filter DMX_PES_TELETEXT2 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_TELETEXT2;
break;
case 14:
msg_Dbg( p_input, "Demux set filter DMX_PES_SUBTITLE2 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_SUBTITLE2;
break;
case 15:
msg_Dbg( p_input, "Demux set filter DMX_PES_PCR2 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_PCR2;
break;
/* Forth device */
case 16:
msg_Dbg( p_input, "Demux set filter DMX_PES_VIDEO3 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_VIDEO3;
break;
case 17:
msg_Dbg( p_input, "Demux set filter DMX_PES_AUDIO3 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_AUDIO3;
break;
case 18:
msg_Dbg( p_input, "Demux set filter DMX_PES_TELETEXT3 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_TELETEXT3;
break;
case 19:
msg_Dbg( p_input, "Demux set filter DMX_PES_SUBTITLE3 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_SUBTITLE3;
break;
case 20:
msg_Dbg( p_input, "Demux set filter DMX_PES_PCR3 for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_PCR3;
break;
/* Usually used by Nova cards */
case 21:
msg_Dbg( p_input, "Demux set filter DMX_PES_OTHER for PMT %d", i_pid );
s_filter_params.pes_type = DMX_PES_OTHER;
break;
/* What to do with i? */
default:
msg_Err( p_input, "trying to set PMT id to=%d for unknown type %d", i_pid, i_type );
break;
}
s_filter_params.flags = DMX_IMMEDIATE_START;
/* We then give the order to the device : */
if( (result = ioctl( *pi_fd, DMX_SET_PES_FILTER, &s_filter_params )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "Demux set filter ioctl failed with %d (%s)", result, strerror( errno ) );
# else
msg_Err( p_input, "Demux set filter ioctl failed with %d", result );
# endif
return -1;
}
return 0;
}
/*****************************************************************************
* ioctl_UnsetDMXFilter : removes a filter
*****************************************************************************/
int ioctl_UnsetDMXFilter( input_thread_t * p_input, int pi_fd )
{
int i_ret;
if( (i_ret = ioctl( pi_fd, DMX_STOP )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "ioctl DMX_STOP failed for demux %d (%d) %s", pi_fd, i_ret, strerror( errno ) );
# else
msg_Err( p_input, "ioctl DMX_STOP failed for demux %d (%d)", pi_fd, i_ret );
# endif
return -1;
}
msg_Dbg( p_input, "ioctl_UnsetDMXFilter closing demux %d", pi_fd );
close( pi_fd );
return 0;
}
/*****************************************************************************
* dvb_DecodeBandwidth : decodes arguments for DVB S/C/T card
*****************************************************************************/
fe_bandwidth_t dvb_DecodeBandwidth( input_thread_t * p_input, int bandwidth )
{
fe_bandwidth_t fe_bandwidth = 0;
switch( bandwidth )
{
case 0:
fe_bandwidth = BANDWIDTH_AUTO;
break;
case 6:
fe_bandwidth = BANDWIDTH_6_MHZ;
break;
case 7:
fe_bandwidth = BANDWIDTH_7_MHZ;
break;
case 8:
fe_bandwidth = BANDWIDTH_8_MHZ;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has bandwidth not set, using auto" );
fe_bandwidth = BANDWIDTH_AUTO;
break;
}
return fe_bandwidth;
}
fe_code_rate_t dvb_DecodeFEC( input_thread_t * p_input, int fec )
{
fe_code_rate_t fe_fec = FEC_NONE;
switch( fec )
{
case 1:
fe_fec = FEC_1_2;
break;
case 2:
fe_fec = FEC_2_3;
break;
case 3:
fe_fec = FEC_3_4;
break;
case 4:
fe_fec = FEC_4_5;
break;
case 5:
fe_fec = FEC_5_6;
break;
case 6:
fe_fec = FEC_6_7;
break;
case 7:
fe_fec = FEC_7_8;
break;
case 8:
fe_fec = FEC_8_9;
break;
case 9:
fe_fec = FEC_AUTO;
break;
default:
/* cannot happen */
fe_fec = FEC_NONE;
msg_Err( p_input, "argument has invalid FEC (%d)", fec );
break;
}
return fe_fec;
}
fe_modulation_t dvb_DecodeModulation( input_thread_t * p_input, int modulation )
{
fe_modulation_t fe_modulation = 0;
switch( modulation )
{
case -1:
fe_modulation = QPSK;
break;
case 0:
fe_modulation = QAM_AUTO;
break;
case 16:
fe_modulation = QAM_16;
break;
case 32:
fe_modulation = QAM_32;
break;
case 64:
fe_modulation = QAM_64;
break;
case 128:
fe_modulation = QAM_128;
break;
case 256:
fe_modulation = QAM_256;
break;
default:
msg_Dbg( p_input, "terrestrial/cable dvb has constellation/modulation not set, using auto" );
fe_modulation = QAM_AUTO;
break;
}
return fe_modulation;
}
fe_transmit_mode_t dvb_DecodeTransmission( input_thread_t * p_input, int transmission )
{
fe_transmit_mode_t fe_transmission = 0;
switch( transmission )
{
case 0:
fe_transmission = TRANSMISSION_MODE_AUTO;
break;
case 2:
fe_transmission = TRANSMISSION_MODE_2K;
break;
case 8:
fe_transmission = TRANSMISSION_MODE_8K;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has transmission mode not set, using auto" );
fe_transmission = TRANSMISSION_MODE_AUTO;
break;
}
return fe_transmission;
}
fe_guard_interval_t dvb_DecodeGuardInterval( input_thread_t * p_input, int guard )
{
fe_guard_interval_t fe_guard = 0;
switch( guard )
{
case 0:
fe_guard = GUARD_INTERVAL_AUTO;
break;
case 4:
fe_guard = GUARD_INTERVAL_1_4;
break;
case 8:
fe_guard = GUARD_INTERVAL_1_8;
break;
case 16:
fe_guard = GUARD_INTERVAL_1_16;
break;
case 32:
fe_guard = GUARD_INTERVAL_1_32;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has guard interval not set, using auto" );
fe_guard = GUARD_INTERVAL_AUTO;
break;
}
return fe_guard;
}
fe_hierarchy_t dvb_DecodeHierarchy( input_thread_t * p_input, int hierarchy )
{
fe_hierarchy_t fe_hierarchy = 0;
switch( hierarchy )
{
case -1:
fe_hierarchy = HIERARCHY_NONE;
break;
case 0:
fe_hierarchy = HIERARCHY_AUTO;
break;
case 1:
fe_hierarchy = HIERARCHY_1;
break;
case 2:
fe_hierarchy = HIERARCHY_2;
break;
case 4:
fe_hierarchy = HIERARCHY_4;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has hierarchy not set, using auto" );
fe_hierarchy = HIERARCHY_AUTO;
break;
}
return fe_hierarchy;
}
fe_spectral_inversion_t dvb_DecodeInversion( input_thread_t * p_input, int inversion )
{
fe_spectral_inversion_t fe_inversion=0;
switch( inversion )
{
case 0:
fe_inversion = INVERSION_OFF;
break;
case 1:
fe_inversion = INVERSION_ON;
break;
case 2:
fe_inversion = INVERSION_AUTO;
break;
default:
msg_Dbg( p_input, "dvb has inversion/polarisation not set, using auto" );
fe_inversion = INVERSION_AUTO;
break;
}
return fe_inversion;
}
/*****************************************************************************
* dvb.h : functions to control a DVB card under Linux with v4l2
*****************************************************************************
* Copyright (C) 1998-2003 VideoLAN
* Copyright (C) 1998-2004 VideoLAN
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@saman>
* Christopher Ross <chris@tebibyte.org>
* Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -30,54 +31,43 @@
#define FRONTEND "/dev/dvb/adapter%d/frontend%d"
#define DVR "/dev/dvb/adapter%d/dvr%d"
/*****************************************************************************
* DVB input data structure
* Local structures
*****************************************************************************/
typedef struct
typedef struct demux_handle_t
{
int i_frontend;
unsigned int u_adapter;
unsigned int u_device;
unsigned int u_freq;
unsigned int u_srate;
unsigned int u_lnb_lof1;
unsigned int u_lnb_lof2;
unsigned int u_lnb_slof;
int i_bandwidth;
int i_modulation;
int i_guard;
int i_transmission;
int i_hierarchy;
int i_polarisation;
int i_fec;
int i_code_rate_HP;
int i_code_rate_LP;
vlc_bool_t b_diseqc;
vlc_bool_t b_probe;
int i_pid;
int i_handle;
int i_type;
} demux_handle_t;
input_socket_t * p_satellite;
} input_dvb_t;
#define MAX_DEMUX 24
typedef struct thread_dvb_data_t
{
int i_handle;
demux_handle_t p_demux_handles[MAX_DEMUX];
void * p_frontend;
vlc_bool_t b_budget_mode;
} thread_dvb_data_t;
/*****************************************************************************
* Prototypes
*****************************************************************************/
int ioctl_SetQPSKFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep );
int ioctl_SetOFDMFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep );
int ioctl_SetQAMFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep );
int ioctl_SetDMXFilter( input_thread_t * p_input, int i_pid, int *pi_fd, int i_type );
int ioctl_UnsetDMXFilter( input_thread_t * p_input, int pi_fd );
int ioctl_InfoFrontend( input_thread_t * p_input, struct dvb_frontend_info *info );
#define VIDEO0_TYPE 1
#define AUDIO0_TYPE 2
#define TELETEXT0_TYPE 3
#define SUBTITLE0_TYPE 4
#define PCR0_TYPE 5
#define TYPE_INTERVAL 5
#define OTHER_TYPE 21
/*****************************************************************************
* dvb argument helper functions
* Prototypes
*****************************************************************************/
fe_bandwidth_t dvb_DecodeBandwidth( input_thread_t * p_input, int bandwidth );
fe_code_rate_t dvb_DecodeFEC( input_thread_t * p_input, int fec );
fe_modulation_t dvb_DecodeModulation( input_thread_t * p_input, int modulation );
fe_transmit_mode_t dvb_DecodeTransmission( input_thread_t * p_input, int transmission );
fe_guard_interval_t dvb_DecodeGuardInterval( input_thread_t * p_input, int guard );
fe_hierarchy_t dvb_DecodeHierarchy( input_thread_t * p_input, int hierarchy );
fe_spectral_inversion_t dvb_DecodeInversion( input_thread_t * p_input, int inversion);
int E_(FrontendOpen)( input_thread_t * p_input );
void E_(FrontendClose)( input_thread_t * p_input );
int E_(FrontendSet)( input_thread_t * p_input );
int E_(DMXSetFilter)( input_thread_t * p_input, int i_pid, int * pi_fd,
int i_type );
int E_(DMXUnsetFilter)( input_thread_t * p_input, int i_fd );
int E_(DVROpen)( input_thread_t * p_input );
void E_(DVRClose)( input_thread_t * p_input );
/*****************************************************************************
* dvb.c : functions to control a DVB card under Linux with v4l2
*****************************************************************************
* Copyright (C) 1998-2004 VideoLAN
*
* Authors: Damien Lucas <nitrox@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@wxs.nl>
* Christopher Ross <chris@tebibyte.org>
* Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <sys/ioctl.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
# include <string.h>
# include <errno.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
/* DVB Card Drivers */
#include <linux/dvb/version.h>
#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
#include <linux/errno.h>
#include "dvb.h"
/*
* Frontends
*/
typedef struct frontend_t {
int i_handle;
struct dvb_frontend_info info;
} frontend_t;
/* Local prototypes */
static int FrontendInfo( input_thread_t * p_input );
static int FrontendSetQPSK( input_thread_t * p_input );
static int FrontendSetQAM( input_thread_t * p_input );
static int FrontendSetOFDM( input_thread_t * p_input );
static int FrontendCheck( input_thread_t * p_input );
/*****************************************************************************
* FrontendOpen : Determine frontend device information and capabilities
*****************************************************************************/
int E_(FrontendOpen)( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend;
unsigned int i_adapter, i_device;
vlc_bool_t b_probe;
char frontend[128];
vlc_value_t val;
var_Get( p_input, "dvb-adapter", &val );
i_adapter = val.i_int;
var_Get( p_input, "dvb-device", &val );
i_device = val.i_int;
var_Get( p_input, "dvb-probe", &val );
b_probe = val.b_bool;
if ( snprintf( frontend, sizeof(frontend), FRONTEND, i_adapter, i_device )
>= (int)sizeof(frontend) )
{
msg_Err( p_input, "snprintf() truncated string for FRONTEND" );
frontend[sizeof(frontend) - 1] = '\0';
}
p_frontend = malloc(sizeof(frontend_t));
p_dvb->p_frontend = p_frontend;
msg_Dbg( p_input, "Opening device %s", frontend );
if ( (p_frontend->i_handle = open(frontend, O_RDWR | O_NONBLOCK)) < 0 )
{
msg_Err( p_input, "FrontEndOpen: opening device failed (%s)",
strerror(errno) );
free( p_frontend );
return -1;
}
if ( b_probe )
{
char * psz_expected = NULL;
char * psz_real;
if ( FrontendInfo( p_input ) < 0 )
{
close( p_frontend->i_handle );
free( p_frontend );
return -1;
}
switch ( p_frontend->info.type )
{
case FE_OFDM:
psz_real = "DVB-T";
break;
case FE_QAM:
psz_real = "DVB-C";
break;
case FE_QPSK:
psz_real = "DVB-S";
break;
default:
psz_real = "unknown";
}
/* Sanity checks */
if( ((strncmp( p_input->psz_access, "qpsk", 4 ) == 0) ||
(strncmp( p_input->psz_access, "dvb-s", 5 ) == 0) ||
(strncmp( p_input->psz_access, "satellite", 9 ) == 0) ) &&
(p_frontend->info.type != FE_QPSK) )
{
psz_expected = "DVB-S";
}
if( ((strncmp( p_input->psz_access, "cable", 5 ) == 0) ||
(strncmp( p_input->psz_access, "dvb-c", 5 ) == 0) ) &&
(p_frontend->info.type != FE_QAM) )
{
psz_expected = "DVB-C";
}
if( ((strncmp( p_input->psz_access, "terrestrial", 11 ) == 0) ||
(strncmp( p_input->psz_access, "dvb-t", 5 ) == 0) ) &&
(p_frontend->info.type != FE_OFDM) )
{
psz_expected = "DVB-T";
}
if ( psz_expected != NULL )
{
msg_Err( p_input, "the user asked for %s, and the tuner is %s",
psz_expected, psz_real );
close( p_frontend->i_handle );
free( p_frontend );
return -1;
}
}
else /* no frontend probing is done so use default border values. */
{
msg_Dbg( p_input, "using default values for frontend info" );
msg_Dbg( p_input, "method of access is %s", p_input->psz_access );
p_frontend->info.type = FE_QPSK;
if ( !strncmp( p_input->psz_access, "qpsk", 4 ) ||
!strncmp( p_input->psz_access, "dvb-s", 5 ) )
p_frontend->info.type = FE_QPSK;
else if ( !strncmp( p_input->psz_access, "cable", 5 ) ||
!strncmp( p_input->psz_access, "dvb-c", 5 ) )
p_frontend->info.type = FE_QAM;
else if ( !strncmp( p_input->psz_access, "terrestrial", 11 ) ||
!strncmp( p_input->psz_access, "dvb-t", 5 ) )
p_frontend->info.type = FE_OFDM;
}
return 0;
}
/*****************************************************************************
* FrontendClose : Close the frontend
*****************************************************************************/
void E_(FrontendClose)( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
if ( p_frontend != NULL )
{
close( p_frontend->i_handle );
free( p_frontend );
}
}
/*****************************************************************************
* FrontendSet : Tune !
*****************************************************************************/
int E_(FrontendSet)( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
switch ( p_frontend->info.type )
{
/* DVB-S: satellite and budget cards (nova) */
case FE_QPSK:
if ( FrontendSetQPSK( p_input ) < 0 )
{
msg_Err( p_input, "DVB-S: tuning failed" );
return -1;
}
break;
/* DVB-C */
case FE_QAM:
if ( FrontendSetQAM( p_input ) < 0 )
{
msg_Err( p_input, "DVB-C: tuning failed" );
return -1;
}
break;
/* DVB-T */
case FE_OFDM:
if ( FrontendSetOFDM( p_input ) < 0 )
{
msg_Err( p_input, "DVB-T: tuning failed" );
return -1;
}
break;
default:
msg_Err( p_input, "Could not determine frontend type on %s",
p_frontend->info.name );
return -1;
}
return 0;
}
/*****************************************************************************
* FrontendInfo : Return information about given frontend
*****************************************************************************/
static int FrontendInfo( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
int i_ret;
/* Determine type of frontend */
if ( (i_ret = ioctl( p_frontend->i_handle, FE_GET_INFO,
&p_frontend->info )) < 0 )
{
msg_Err( p_input, "ioctl FE_GET_INFO failed (%d) %s", i_ret,
strerror(errno) );
return -1;
}
/* Print out frontend capabilities. */
msg_Dbg(p_input, "Frontend Info:" );
msg_Dbg(p_input, " name = %s", p_frontend->info.name);
switch ( p_frontend->info.type )
{
case FE_QPSK:
msg_Dbg( p_input, " type = QPSK (DVB-S)" );
break;
case FE_QAM:
msg_Dbg( p_input, " type = QAM (DVB-C)" );
break;
case FE_OFDM:
msg_Dbg( p_input, " type = OFDM (DVB-T)" );
break;
#if 0 /* DVB_API_VERSION == 3 */
case FE_MEMORY:
msg_Dbg(p_input, " type = MEMORY" );
break;
case FE_NET:
msg_Dbg(p_input, " type = NETWORK" );
break;
#endif
default:
msg_Err( p_input, " unknown frontend type (%d)",
p_frontend->info.type );
return -1;
}
msg_Dbg(p_input, " frequency_min = %u (kHz)",
p_frontend->info.frequency_min);
msg_Dbg(p_input, " frequency_max = %u (kHz)",
p_frontend->info.frequency_max);
msg_Dbg(p_input, " frequency_stepsize = %u",
p_frontend->info.frequency_stepsize);
msg_Dbg(p_input, " frequency_tolerance = %u",
p_frontend->info.frequency_tolerance);
msg_Dbg(p_input, " symbol_rate_min = %u (kHz)",
p_frontend->info.symbol_rate_min);
msg_Dbg(p_input, " symbol_rate_max = %u (kHz)",
p_frontend->info.symbol_rate_max);
msg_Dbg(p_input, " symbol_rate_tolerance (ppm) = %u",
p_frontend->info.symbol_rate_tolerance);
msg_Dbg(p_input, " notifier_delay (ms) = %u",
p_frontend->info.notifier_delay );
msg_Dbg(p_input, "Frontend Info capability list:");
if (p_frontend->info.caps & FE_IS_STUPID)
msg_Dbg(p_input, " no capabilities - frontend is stupid!");
if (p_frontend->info.caps & FE_CAN_INVERSION_AUTO)
msg_Dbg(p_input, " inversion auto");
if (p_frontend->info.caps & FE_CAN_FEC_1_2)
msg_Dbg(p_input, " forward error correction 1/2");
if (p_frontend->info.caps & FE_CAN_FEC_2_3)
msg_Dbg(p_input, " forward error correction 2/3");
if (p_frontend->info.caps & FE_CAN_FEC_3_4)
msg_Dbg(p_input, " forward error correction 3/4");
if (p_frontend->info.caps & FE_CAN_FEC_4_5)
msg_Dbg(p_input, " forward error correction 4/5");
if (p_frontend->info.caps & FE_CAN_FEC_5_6)
msg_Dbg(p_input, " forward error correction 5/6");
if (p_frontend->info.caps & FE_CAN_FEC_6_7)
msg_Dbg(p_input, " forward error correction 6/7");
if (p_frontend->info.caps & FE_CAN_FEC_7_8)
msg_Dbg(p_input, " forward error correction 7/8");
if (p_frontend->info.caps & FE_CAN_FEC_8_9)
msg_Dbg(p_input, " forward error correction 8/9");
if (p_frontend->info.caps & FE_CAN_FEC_AUTO)
msg_Dbg(p_input, " forward error correction auto");
if (p_frontend->info.caps & FE_CAN_QPSK)
msg_Dbg(p_input, " card can do QPSK");
if (p_frontend->info.caps & FE_CAN_QAM_16)
msg_Dbg(p_input, " card can do QAM 16");
if (p_frontend->info.caps & FE_CAN_QAM_32)
msg_Dbg(p_input, " card can do QAM 32");
if (p_frontend->info.caps & FE_CAN_QAM_64)
msg_Dbg(p_input, " card can do QAM 64");
if (p_frontend->info.caps & FE_CAN_QAM_128)
msg_Dbg(p_input, " card can do QAM 128");
if (p_frontend->info.caps & FE_CAN_QAM_256)
msg_Dbg(p_input, " card can do QAM 256");
if (p_frontend->info.caps & FE_CAN_QAM_AUTO)
msg_Dbg(p_input, " card can do QAM auto");
if (p_frontend->info.caps & FE_CAN_TRANSMISSION_MODE_AUTO)
msg_Dbg(p_input, " transmission mode auto");
if (p_frontend->info.caps & FE_CAN_BANDWIDTH_AUTO)
msg_Dbg(p_input, " bandwidth mode auto");
if (p_frontend->info.caps & FE_CAN_GUARD_INTERVAL_AUTO)
msg_Dbg(p_input, " guard interval mode auto");
if (p_frontend->info.caps & FE_CAN_HIERARCHY_AUTO)
msg_Dbg(p_input, " hierarchy mode auto");
if (p_frontend->info.caps & FE_CAN_MUTE_TS)
msg_Dbg(p_input, " card can mute TS");
if (p_frontend->info.caps & FE_CAN_CLEAN_SETUP)
msg_Dbg(p_input, " clean setup");
msg_Dbg(p_input, "End of capability list");
return 0;
}
/*****************************************************************************
* Decoding the DVB parameters (common)
*****************************************************************************/
static fe_spectral_inversion_t DecodeInversion( input_thread_t * p_input )
{
vlc_value_t val;
fe_spectral_inversion_t fe_inversion = 0;
var_Get( p_input, "dvb-inversion", &val );
msg_Dbg( p_input, "using inversion=%d", val.i_int );
switch ( val.i_int )
{
case 0: fe_inversion = INVERSION_OFF; break;
case 1: fe_inversion = INVERSION_ON; break;
case 2: fe_inversion = INVERSION_AUTO; break;
default:
msg_Dbg( p_input, "dvb has inversion not set, using auto");
fe_inversion = INVERSION_AUTO;
break;
}
return fe_inversion;
}
static fe_code_rate_t DecodeFEC( input_thread_t * p_input, int i_val )
{
fe_code_rate_t fe_fec = FEC_NONE;
msg_Dbg( p_input, "using feq=%d", i_val );
switch ( i_val )
{
case 1: fe_fec = FEC_1_2; break;
case 2: fe_fec = FEC_2_3; break;
case 3: fe_fec = FEC_3_4; break;
case 4: fe_fec = FEC_4_5; break;
case 5: fe_fec = FEC_5_6; break;
case 6: fe_fec = FEC_6_7; break;
case 7: fe_fec = FEC_7_8; break;
case 8: fe_fec = FEC_8_9; break;
case 9: fe_fec = FEC_AUTO; break;
default:
/* cannot happen */
fe_fec = FEC_NONE;
msg_Err( p_input, "argument has invalid FEC (%d)", i_val);
break;
}
return fe_fec;
}
static fe_modulation_t DecodeModulation( input_thread_t * p_input )
{
vlc_value_t val;
fe_modulation_t fe_modulation = 0;
var_Get( p_input, "dvb-modulation", &val );
switch ( val.i_int )
{
case -1: fe_modulation = QPSK; break;
case 0: fe_modulation = QAM_AUTO; break;
case 16: fe_modulation = QAM_16; break;
case 32: fe_modulation = QAM_32; break;
case 64: fe_modulation = QAM_64; break;
case 128: fe_modulation = QAM_128; break;
case 256: fe_modulation = QAM_256; break;
default:
msg_Dbg( p_input, "terrestrial/cable dvb has constellation/modulation not set, using auto");
fe_modulation = QAM_AUTO;
break;
}
return fe_modulation;
}
/*****************************************************************************
* FrontendSetQPSK : controls the FE device
*****************************************************************************/
static fe_sec_voltage_t DecodeVoltage( input_thread_t * p_input )
{
vlc_value_t val;
fe_sec_voltage_t fe_voltage;
var_Get( p_input, "dvb-voltage", &val );
msg_Dbg( p_input, "using voltage=%d", val.i_int );
switch ( val.i_int )
{
case 0: fe_voltage = SEC_VOLTAGE_OFF; break;
case 13: fe_voltage = SEC_VOLTAGE_13; break;
case 18: fe_voltage = SEC_VOLTAGE_18; break;
default:
fe_voltage = SEC_VOLTAGE_OFF;
msg_Err( p_input, "argument has invalid voltage (%d)", val.i_int);
break;
}
return fe_voltage;
}
static fe_sec_tone_mode_t DecodeTone( input_thread_t * p_input )
{
vlc_value_t val;
fe_sec_tone_mode_t fe_tone;
var_Get( p_input, "dvb-tone", &val );
msg_Dbg( p_input, "using tone=%d", val.i_int );
switch ( val.i_int )
{
case 0: fe_tone = SEC_TONE_OFF; break;
case 1: fe_tone = SEC_TONE_ON; break;
default:
fe_tone = SEC_TONE_OFF;
msg_Err( p_input, "argument has invalid tone mode (%d)", val.i_int);
break;
}
return fe_tone;
}
struct diseqc_cmd_t
{
struct dvb_diseqc_master_cmd cmd;
uint32_t wait;
};
static int DoDiseqc( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
vlc_value_t val;
int i_frequency, i_lnb_slof;
fe_sec_voltage_t fe_voltage;
fe_sec_tone_mode_t fe_tone;
int i_err;
var_Get( p_input, "dvb-frequency", &val );
i_frequency = val.i_int;
var_Get( p_input, "dvb-lnb-slof", &val );
i_lnb_slof = val.i_int;
var_Get( p_input, "dvb-tone", &val );
if ( val.i_int == -1 /* auto */ )
{
if ( i_frequency >= i_lnb_slof )
val.i_int = 1;
else
val.i_int = 0;
var_Set( p_input, "dvb-tone", val );
}
fe_voltage = DecodeVoltage( p_input );
fe_tone = DecodeTone( p_input );
if ( (i_err = ioctl( p_frontend->i_handle, FE_SET_VOLTAGE, fe_voltage )) < 0 )
{
msg_Err( p_input, "ioctl FE_SET_VOLTAGE failed, voltage=%d (%d) %s",
fe_voltage, i_err, strerror(errno) );
return i_err;
}
var_Get( p_input, "dvb-satno", &val );
if ( val.i_int != 0 )
{
/* digital satellite equipment control,
* specification is available from http://www.eutelsat.com/
*/
if ( (i_err = ioctl( p_frontend->i_handle, FE_SET_TONE,
SEC_TONE_OFF )) < 0 )
{
msg_Err( p_input, "ioctl FE_SET_TONE failed, tone=off (%d) %s",
i_err, strerror(errno) );
return i_err;
}
msleep(15000);
if ( val.i_int >= 1 && val.i_int <= 4 )
{
/* 1.x compatible equipment */
struct diseqc_cmd_t cmd = { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };
/* param: high nibble: reset bits, low nibble set bits,
* bits are: option, position, polarization, band
*/
cmd.cmd.msg[3] = 0xf0 /* reset bits */
| (((val.i_int - 1) * 4) & 0xc)
| (fe_voltage == SEC_VOLTAGE_13 ? 0 : 2)
| (fe_tone == SEC_TONE_ON ? 1 : 0);
if ( (i_err = ioctl( p_frontend->i_handle, FE_DISEQC_SEND_MASTER_CMD,
&cmd.cmd )) < 0 )
{
msg_Err( p_input, "ioctl FE_SEND_MASTER_CMD failed (%d) %s",
i_err, strerror(errno) );
return i_err;
}
msleep(cmd.wait * 1000);
}
else
{
/* A or B simple diseqc */
if ( (i_err = ioctl( p_frontend->i_handle, FE_DISEQC_SEND_BURST,
val.i_int == -1 ? SEC_MINI_A : SEC_MINI_B )) < 0 )
{
msg_Err( p_input, "ioctl FE_SEND_BURST failed (%d) %s",
i_err, strerror(errno) );
return i_err;
}
}
msleep(15000);
}
if ( (i_err = ioctl( p_frontend->i_handle, FE_SET_TONE, fe_tone )) < 0 )
{
msg_Err( p_input, "ioctl FE_SET_TONE failed, tone=%s (%d) %s",
fe_tone == SEC_TONE_ON ? "on" : "off", i_err,
strerror(errno) );
return i_err;
}
msleep(15000);
return 0;
}
static int FrontendSetQPSK( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
struct dvb_frontend_parameters fep;
int i_ret;
vlc_value_t val;
int i_frequency, i_lnb_slof;
/* Prepare the fep structure */
var_Get( p_input, "dvb-frequency", &val );
i_frequency = val.i_int;
var_Get( p_input, "dvb-lnb-slof", &val );
i_lnb_slof = val.i_int;
if ( i_frequency >= i_lnb_slof )
var_Get( p_input, "dvb-lnb-lof2", &val );
else
var_Get( p_input, "dvb-lnb-lof1", &val );
fep.frequency = i_frequency - val.i_int;
fep.inversion = DecodeInversion( p_input );
var_Get( p_input, "dvb-srate", &val );
fep.u.qpsk.symbol_rate = val.i_int;
var_Get( p_input, "dvb-fec", &val );
fep.u.qpsk.fec_inner = DecodeFEC( p_input, val.i_int );
if ( DoDiseqc( p_input ) < 0 )
{
return -1;
}
msleep(100000);
/* Empty the event queue */
for ( ; ; )
{
struct dvb_frontend_event event;
if ( ioctl( p_frontend->i_handle, FE_GET_EVENT, &event ) < 0 )
break;
}
/* Now send it all to the frontend device */
if ( (i_ret = ioctl( p_frontend->i_handle, FE_SET_FRONTEND, &fep )) < 0 )
{
msg_Err( p_input, "DVB-S: setting frontend failed (%d) %s", i_ret,
strerror(errno) );
return -1;
}
return FrontendCheck( p_input );
}
/*****************************************************************************
* FrontendSetQAM : controls the FE device
*****************************************************************************/
static int FrontendSetQAM( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
struct dvb_frontend_parameters fep;
vlc_value_t val;
int i_ret;
/* Prepare the fep structure */
var_Get( p_input, "dvb-frequency", &val );
fep.frequency = val.i_int;
fep.inversion = DecodeInversion( p_input );
var_Get( p_input, "dvb-srate", &val );
fep.u.qam.symbol_rate = val.i_int;
var_Get( p_input, "dvb-fec", &val );
fep.u.qam.fec_inner = DecodeFEC( p_input, val.i_int );
fep.u.qam.modulation = DecodeModulation( p_input );
/* Now send it all to the frontend device */
if ( (i_ret = ioctl( p_frontend->i_handle, FE_SET_FRONTEND, &fep )) < 0 )
{
msg_Err( p_input, "DVB-C: setting frontend failed (%d) %s", i_ret,
strerror(errno) );
return -1;
}
return FrontendCheck( p_input );
}
/*****************************************************************************
* FrontendSetOFDM : controls the FE device
*****************************************************************************/
static fe_bandwidth_t DecodeBandwidth( input_thread_t * p_input )
{
vlc_value_t val;
fe_bandwidth_t fe_bandwidth = 0;
var_Get( p_input, "dvb-bandwidth", &val );
msg_Dbg( p_input, "using bandwidth=%d", val.i_int );
switch ( val.i_int )
{
case 0: fe_bandwidth = BANDWIDTH_AUTO; break;
case 6: fe_bandwidth = BANDWIDTH_6_MHZ; break;
case 7: fe_bandwidth = BANDWIDTH_7_MHZ; break;
case 8: fe_bandwidth = BANDWIDTH_8_MHZ; break;
default:
msg_Dbg( p_input, "terrestrial dvb has bandwidth not set, using auto" );
fe_bandwidth = BANDWIDTH_AUTO;
break;
}
return fe_bandwidth;
}
static fe_transmit_mode_t DecodeTransmission( input_thread_t * p_input )
{
vlc_value_t val;
fe_transmit_mode_t fe_transmission = 0;
var_Get( p_input, "dvb-transmission", &val );
msg_Dbg( p_input, "using transmission=%d", val.i_int );
switch ( val.i_int )
{
case 0: fe_transmission = TRANSMISSION_MODE_AUTO; break;
case 2: fe_transmission = TRANSMISSION_MODE_2K; break;
case 8: fe_transmission = TRANSMISSION_MODE_8K; break;
default:
msg_Dbg( p_input, "terrestrial dvb has transmission mode not set, using auto");
fe_transmission = TRANSMISSION_MODE_AUTO;
break;
}
return fe_transmission;
}
static fe_guard_interval_t DecodeGuardInterval( input_thread_t * p_input )
{
vlc_value_t val;
fe_guard_interval_t fe_guard = 0;
var_Get( p_input, "dvb-guard", &val );
msg_Dbg( p_input, "using guard=%d", val.i_int );
switch ( val.i_int )
{
case 0: fe_guard = GUARD_INTERVAL_AUTO; break;
case 4: fe_guard = GUARD_INTERVAL_1_4; break;
case 8: fe_guard = GUARD_INTERVAL_1_8; break;
case 16: fe_guard = GUARD_INTERVAL_1_16; break;
case 32: fe_guard = GUARD_INTERVAL_1_32; break;
default:
msg_Dbg( p_input, "terrestrial dvb has guard interval not set, using auto");
fe_guard = GUARD_INTERVAL_AUTO;
break;
}
return fe_guard;
}
static fe_hierarchy_t DecodeHierarchy( input_thread_t * p_input )
{
vlc_value_t val;
fe_hierarchy_t fe_hierarchy = 0;
var_Get( p_input, "dvb-hierarchy", &val );
msg_Dbg( p_input, "using hierarchy=%d", val.i_int );
switch ( val.i_int )
{
case -1: fe_hierarchy = HIERARCHY_NONE; break;
case 0: fe_hierarchy = HIERARCHY_AUTO; break;
case 1: fe_hierarchy = HIERARCHY_1; break;
case 2: fe_hierarchy = HIERARCHY_2; break;
case 4: fe_hierarchy = HIERARCHY_4; break;
default:
msg_Dbg( p_input, "terrestrial dvb has hierarchy not set, using auto");
fe_hierarchy = HIERARCHY_AUTO;
break;
}
return fe_hierarchy;
}
static int FrontendSetOFDM( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
struct dvb_frontend_parameters fep;
vlc_value_t val;
int ret;
/* Prepare the fep structure */
var_Get( p_input, "dvb-frequency", &val );
fep.frequency = val.i_int;
fep.inversion = DecodeInversion( p_input );
fep.u.ofdm.bandwidth = DecodeBandwidth( p_input );
var_Get( p_input, "dvb-code-rate-HP", &val );
fep.u.ofdm.code_rate_HP = DecodeFEC( p_input, val.i_int );
var_Get( p_input, "dvb-code-rate-LP", &val );
fep.u.ofdm.code_rate_LP = DecodeFEC( p_input, val.i_int );
fep.u.ofdm.constellation = DecodeModulation( p_input );
fep.u.ofdm.transmission_mode = DecodeTransmission( p_input );
fep.u.ofdm.guard_interval = DecodeGuardInterval( p_input );
fep.u.ofdm.hierarchy_information = DecodeHierarchy( p_input );
/* Now send it all to the frontend device */
if ( (ret = ioctl( p_frontend->i_handle, FE_SET_FRONTEND, &fep )) < 0 )
{
msg_Err( p_input, "DVB-T: setting frontend failed (%d) %s", ret,
strerror(errno) );
return -1;
}
return FrontendCheck( p_input );
}
/******************************************************************
* FrontendCheck: Check completion of the frontend control sequence
******************************************************************/
static int FrontendCheck( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
frontend_t * p_frontend = (frontend_t *)p_dvb->p_frontend;
int i_ret;
while ( !p_input->b_die && !p_input->b_error )
{
fe_status_t status;
if ( (i_ret = ioctl( p_frontend->i_handle, FE_READ_STATUS,
&status )) < 0 )
{
msg_Err( p_input, "reading frontend status failed (%d) %s",
i_ret, strerror(errno) );
return i_ret;
}
if (status & FE_HAS_SIGNAL) /* found something above the noise level */
msg_Dbg(p_input, "check frontend ... has signal");
if (status & FE_HAS_CARRIER) /* found a DVB signal */
msg_Dbg(p_input, "check frontend ... has carrier");
if (status & FE_HAS_VITERBI) /* FEC is stable */
msg_Dbg(p_input, "check frontend ... has stable forward error correction");
if (status & FE_HAS_SYNC) /* found sync bytes */
msg_Dbg(p_input, "check frontend ... has sync");
if (status & FE_HAS_LOCK) /* everything's working... */
{
int32_t value;
msg_Dbg(p_input, "check frontend ... has lock");
msg_Dbg(p_input, "tuning succeeded");
/* Read some statistics */
value = 0;
if ( ioctl( p_frontend->i_handle, FE_READ_BER, &value ) >= 0 )
msg_Dbg( p_input, "Bit error rate: %d", value );
value = 0;
if ( ioctl( p_frontend->i_handle, FE_READ_SIGNAL_STRENGTH, &value ) >= 0 )
msg_Dbg( p_input, "Signal strength: %d", value );
value = 0;
if ( ioctl( p_frontend->i_handle, FE_READ_SNR, &value ) >= 0 )
msg_Dbg( p_input, "SNR: %d", value );
return 0;
}
if (status & FE_TIMEDOUT) /* no lock within the last ~2 seconds */
{
msg_Err(p_input, "tuning failed ... timed out");
return -2;
}
if (status & FE_REINIT)
{
/* frontend was reinitialized, */
/* application is recommended to reset */
/* DiSEqC, tone and parameters */
msg_Err(p_input, "tuning failed ... resend frontend parameters");
return -3;
}
msleep(500000);
}
return -1;
}
/*
* Demux
*/
/*****************************************************************************
* DMXSetFilter : controls the demux to add a filter
*****************************************************************************/
int E_(DMXSetFilter)( input_thread_t * p_input, int i_pid, int * pi_fd,
int i_type )
{
struct dmx_pes_filter_params s_filter_params;
int i_ret;
unsigned int i_adapter, i_device;
char dmx[128];
vlc_value_t val;
var_Get( p_input, "dvb-adapter", &val );
i_adapter = val.i_int;
var_Get( p_input, "dvb-device", &val );
i_device = val.i_int;
if ( snprintf( dmx, sizeof(dmx), DMX, i_adapter, i_device )
>= (int)sizeof(dmx) )
{
msg_Err( p_input, "snprintf() truncated string for DMX" );
dmx[sizeof(dmx) - 1] = '\0';
}
msg_Dbg( p_input, "Opening device %s", dmx );
if ( (*pi_fd = open(dmx, O_RDWR)) < 0 )
{
msg_Err( p_input, "DMXSetFilter: opening device failed (%s)",
strerror(errno) );
return -1;
}
/* We fill the DEMUX structure : */
s_filter_params.pid = i_pid;
s_filter_params.input = DMX_IN_FRONTEND;
s_filter_params.output = DMX_OUT_TS_TAP;
s_filter_params.flags = DMX_IMMEDIATE_START;
switch ( i_type )
{ /* First device */
case 1:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_VIDEO0 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_VIDEO0;
break;
case 2:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_AUDIO0 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_AUDIO0;
break;
case 3:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_TELETEXT0 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_TELETEXT0;
break;
case 4:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_SUBTITLE0 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_SUBTITLE0;
break;
case 5:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_PCR0 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_PCR0;
break;
/* Second device */
case 6:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_VIDEO1 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_VIDEO1;
break;
case 7:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_AUDIO1 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_AUDIO1;
break;
case 8:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_TELETEXT1 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_TELETEXT1;
break;
case 9:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_SUBTITLE1 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_SUBTITLE1;
break;
case 10:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_PCR1 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_PCR1;
break;
/* Third device */
case 11:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_VIDEO2 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_VIDEO2;
break;
case 12:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_AUDIO2 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_AUDIO2;
break;
case 13:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_TELETEXT2 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_TELETEXT2;
break;
case 14:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_SUBTITLE2 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_SUBTITLE2;
break;
case 15:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_PCR2 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_PCR2;
break;
/* Forth device */
case 16:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_VIDEO3 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_VIDEO3;
break;
case 17:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_AUDIO3 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_AUDIO3;
break;
case 18:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_TELETEXT3 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_TELETEXT3;
break;
case 19:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_SUBTITLE3 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_SUBTITLE3;
break;
case 20:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_PCR3 for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_PCR3;
break;
/* Usually used by Nova cards */
case 21:
default:
msg_Dbg(p_input, "DMXSetFilter: DMX_PES_OTHER for PID %d", i_pid);
s_filter_params.pes_type = DMX_PES_OTHER;
break;
}
/* We then give the order to the device : */
if ( (i_ret = ioctl( *pi_fd, DMX_SET_PES_FILTER, &s_filter_params )) < 0 )
{
msg_Err( p_input, "DMXSetFilter: failed with %d (%s)", i_ret,
strerror(errno) );
return -1;
}
return 0;
}
/*****************************************************************************
* DMXUnsetFilter : removes a filter
*****************************************************************************/
int E_(DMXUnsetFilter)( input_thread_t * p_input, int i_fd )
{
int i_ret;
if ( (i_ret = ioctl( i_fd, DMX_STOP )) < 0 )
{
msg_Err( p_input, "DMX_STOP failed for demux (%d) %s",
i_ret, strerror(errno) );
return i_ret;
}
msg_Dbg( p_input, "DMXUnsetFilter: closing demux %d", i_fd);
close( i_fd );
return 0;
}
/*
* DVR device
*/
/*****************************************************************************
* DVROpen :
*****************************************************************************/
int E_(DVROpen)( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
unsigned int i_adapter, i_device;
char dvr[128];
vlc_value_t val;
var_Get( p_input, "dvb-adapter", &val );
i_adapter = val.i_int;
var_Get( p_input, "dvb-device", &val );
i_device = val.i_int;
if ( snprintf( dvr, sizeof(dvr), DVR, i_adapter, i_device )
>= (int)sizeof(dvr) )
{
msg_Err( p_input, "snprintf() truncated string for DVR" );
dvr[sizeof(dvr) - 1] = '\0';
}
msg_Dbg( p_input, "Opening device %s", dvr );
if ( (p_dvb->i_handle = open(dvr, O_RDONLY)) < 0 )
{
msg_Err( p_input, "DVROpen: opening device failed (%s)",
strerror(errno) );
return -1;
}
return 0;
}
/*****************************************************************************
* DVRClose :
*****************************************************************************/
void E_(DVRClose)( input_thread_t * p_input )
{
thread_dvb_data_t * p_dvb
= (thread_dvb_data_t *)p_input->p_access_data;
close( p_dvb->i_handle );
}
/*****************************************************************************
* qpsk.c : Satellite input module for vlc
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
*
* Authors: Sam Hocevar <sam@zoy.org>
* Jean-Paul Saman <jpsaman@wxs.nl>
* Christopher Ross <chris@tebibyte.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include <vlc/vlc.h>
/*****************************************************************************
* External prototypes
*****************************************************************************/
int E_(Open) ( vlc_object_t * );
void E_(Close) ( vlc_object_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
/* Satellite options */
#define ADAPTER_TEXT N_("Adapter card to tune")
#define ADAPTER_LONGTEXT N_("Adapter cards have a device file in directory named /dev/dvb/adapter[n] with n>=0.")
#define DEVICE_TEXT N_("Device number to use on adapter")
#define DEVICE_LONGTEXT ""
#define FREQ_TEXT N_("Satellite transponder frequency for DVB-S (kHz) and for DVB-C/T (Hz)")
#define FREQ_LONGTEXT ""
#define POL_TEXT N_("Satellite transponder polarization")
#define POL_LONGTEXT ""
#define FEC_TEXT N_("Satellite transponder FEC")
#define FEC_LONGTEXT N_("FEC=Forward Error Correction mode.")
#define SRATE_TEXT N_("Satellite transponder symbol rate in kHz")
#define SRATE_LONGTEXT ""
#define DISEQC_TEXT N_("Use diseqc with antenna")
#define DISEQC_LONGTEXT ""
#define LNB_LOF1_TEXT N_("Antenna lnb_lof1 (kHz)")
#define LNB_LOF1_LONGTEXT ""
#define LNB_LOF2_TEXT N_("Antenna lnb_lof2 (kHz)")
#define LNB_LOF2_LONGTEXT ""
#define LNB_SLOF_TEXT N_("Antenna lnb_slof (kHz)")
#define LNB_SLOF_LONGTEXT ""
#define PROBE_TEXT N_("Probe DVB card for capabilities")
#define PROBE_LONGTEXT N_("Some DVB cards do not like to be probed for their capabilities.")
/* Cable */
#define MODULATION_TEXT N_("Modulation type")
#define MODULATION_LONGTEXT N_("Modulation type for front-end device.")
/* Terrestrial */
#define CODE_RATE_HP_TEXT N_("Terrestrial high priority stream code rate (FEC)")
#define CODE_RATE_HP_LONGTEXT ""
#define CODE_RATE_LP_TEXT N_("Terrestrial low priority stream code rate (FEC)")
#define CODE_RATE_LP_LONGTEXT ""
#define BANDWIDTH_TEXT N_("Terrestrial bandwidth")
#define BANDWIDTH_LONGTEXT N_("Terrestrial bandwidth [0=auto,6,7,8 in MHz]")
#define GUARD_TEXT N_("Terrestrial guard interval")
#define GUARD_LONGTEXT ""
#define TRANSMISSION_TEXT N_("Terrestrial transmission mode")
#define TRANSMISSION_LONGTEXT ""
#define HIERARCHY_TEXT N_("Terrestrial hierarchy mode")
#define HIERARCHY_LONGTEXT ""
vlc_module_begin();
set_description( _("DVB input with v4l2 support") );
/* General options */
add_bool( "probe", 0, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_FALSE );
add_integer( "adapter", 0, NULL, ADAPTER_TEXT, ADAPTER_LONGTEXT,
VLC_FALSE );
add_integer( "device", 0, NULL, DEVICE_TEXT, DEVICE_LONGTEXT, VLC_FALSE );
add_integer( "frequency", 11954000, NULL, FREQ_TEXT, FREQ_LONGTEXT,
VLC_FALSE );
/* DVB-S (satellite) */
add_integer( "polarization", 0, NULL, POL_TEXT, POL_LONGTEXT, VLC_FALSE );
add_integer( "fec", 3, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_FALSE );
add_integer( "symbol-rate", 27500000, NULL, SRATE_TEXT, SRATE_LONGTEXT,
VLC_FALSE );
add_bool( "diseqc", 0, NULL, DISEQC_TEXT, DISEQC_LONGTEXT, VLC_TRUE );
add_integer( "lnb-lof1", 9750000, NULL, LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT,
VLC_TRUE );
add_integer( "lnb-lof2", 12999000, NULL, LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT,
VLC_TRUE );
add_integer( "lnb-slof", 11700000, NULL, LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT,
VLC_TRUE );
/* DVB-T (terrestrial) */
add_integer( "code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT,
CODE_RATE_HP_LONGTEXT, VLC_TRUE );
add_integer( "code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT,
CODE_RATE_LP_LONGTEXT, VLC_TRUE );
add_integer( "bandwidth", 0, NULL, BANDWIDTH_TEXT, BANDWIDTH_LONGTEXT,
VLC_TRUE );
add_integer( "modulation", 0, NULL, MODULATION_TEXT, MODULATION_LONGTEXT,
VLC_TRUE );
add_integer( "guard", 0, NULL, GUARD_TEXT, GUARD_LONGTEXT, VLC_TRUE );
add_integer( "transmission", 0, NULL, TRANSMISSION_TEXT,
TRANSMISSION_LONGTEXT, VLC_TRUE );
add_integer( "hierarchy", 0, NULL, HIERARCHY_TEXT, HIERARCHY_LONGTEXT,
VLC_TRUE );
/* short cuts */
set_capability( "access", 0 );
add_shortcut( "dvb" ); /* General DVB-C/S/T MRL */
add_shortcut( "dvb-s" ); /* DVB-S (satillite) */
add_shortcut( "qpsk" );
add_shortcut( "dvb-c" ); /* DVB-C (cable) */
add_shortcut( "cable" );
add_shortcut( "dvb-t" ); /* DVB-T (terrestrial) */
add_shortcut( "terrestrial" );
add_shortcut( "satellite" ); /* compatibility with the interface. */
set_callbacks( E_(Open), E_(Close) );
vlc_module_end();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment