Commit e2fc6acb authored by Jean-Paul Saman's avatar Jean-Paul Saman

Refactoring of dvb.c and access.c. Coding style and messages cleanup.

parent 82957718
......@@ -74,99 +74,55 @@ int E_(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_socket_t * p_satellite;
input_dvb_t * p_dvb;
char * psz_parser;
char * psz_next;
int i_fd = 0;
unsigned int u_adapter = 1;
unsigned int u_device = 0;
unsigned int u_freq = 0;
unsigned int u_srate = 0;
unsigned int u_lnb_lof1;
unsigned int u_lnb_lof2;
unsigned int u_lnb_slof;
int i_bandwidth = 0;
int i_modulation = 0;
int i_guard = 0;
int i_transmission = 0;
int i_hierarchy = 0;
int i_polarisation = 0;
int i_fec = 0;
int i_code_rate_HP = 0;
int i_code_rate_LP = 0;
vlc_bool_t b_diseqc;
vlc_bool_t b_probe;
char dvr[] = DVR;
char frontend[] = FRONTEND;
int i_len = 0;
vlc_value_t val;
int i_test;
/* parse the options passed in command line : */
psz_parser = strdup( p_input->psz_name );
if( !psz_parser )
{
return( -1 );
}
// Get adapter and device number to use for this dvb card
u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" );
msg_Dbg(p_input, "method of access is %s", p_input->psz_access);
/* Get antenna configuration options */
b_diseqc = config_GetInt( p_input, "diseqc" );
u_lnb_lof1 = config_GetInt( p_input, "lnb-lof1" );
u_lnb_lof2 = config_GetInt( p_input, "lnb-lof2" );
u_lnb_slof = config_GetInt( p_input, "lnb-slof" );
/*Get modulation parameters*/
i_bandwidth = config_GetInt( p_input, "bandwidth");
i_code_rate_HP = config_GetInt(p_input, "code-rate-hp");
i_code_rate_LP = config_GetInt(p_input, "code-rate-lp");
i_modulation = config_GetInt(p_input, "modulation");
i_transmission = config_GetInt(p_input, "transmission");
i_guard = config_GetInt(p_input, "guard");
i_hierarchy = config_GetInt(p_input, "hierarchy");
/* Initialise structure */
p_dvb = malloc( sizeof( input_dvb_t ) );
/* Determine frontend device information and capabilities */
b_probe = config_GetInt( p_input, "probe" );
if (b_probe)
if( p_dvb == NULL )
{
if ( ioctl_InfoFrontend(p_input, &frontend_info, u_adapter, u_device) < 0 )
{
msg_Err( p_input, "(access) cannot determine frontend info" );
msg_Err( p_input, "out of memory" );
return -1;
}
}
else /* no frontend probing is done so use default border values. */
{
msg_Dbg( p_input, "using default values for frontend info" );
i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{
msg_Err( p_input, "snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0';
}
strncpy(frontend_info.name, frontend, 128);
msg_Dbg(p_input, "method of access is %s", p_input->psz_access);
p_input->p_access_data = (void *) p_dvb;
frontend_info.type = FE_QPSK;
if (strncmp( p_input->psz_access, "qpsk",4 ) ==0)
frontend_info.type = FE_QPSK;
else if (strncmp( p_input->psz_access, "cable",5 ) ==0)
frontend_info.type = FE_QAM;
else if (strncmp( p_input->psz_access, "terrestrial",11) ==0)
frontend_info.type = FE_OFDM;
frontend_info.frequency_max = u_lnb_lof2; /* in KHz, lnb_lof2 */
frontend_info.frequency_min = u_lnb_lof1; /* lnb_lof1 */
/* 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" );
frontend_info.symbol_rate_max = 30000000;
frontend_info.symbol_rate_min = 1000000;
}
/* 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;
......@@ -174,15 +130,16 @@ int E_(Open) ( vlc_object_t *p_this )
p_input->pf_set_area = SatelliteSetArea;
p_input->pf_seek = SatelliteSeek;
/* Parse commandline */
i_test = strtol( psz_parser, &psz_next, 10 );
if ( psz_next == psz_parser )
if( psz_next == psz_parser )
{
for ( ;; )
{
if( !strncmp( psz_parser, "frequency=",
strlen( "frequency=" ) ) )
{
u_freq =
p_dvb->u_freq =
(unsigned int)strtol( psz_parser + strlen( "frequency=" ),
&psz_parser, 0 );
}
......@@ -196,41 +153,41 @@ int E_(Open) ( vlc_object_t *p_this )
{
psz_parser++;
}
if ((!strncmp( psz_parser_init, "V" ,
if( (!strncmp( psz_parser_init, "V" ,
psz_parser - psz_parser_init ) ) ||
(!strncmp( psz_parser_init, "V" ,
psz_parser - psz_parser_init ) ) )
{
i_polarisation = 0; //VLC_FALSE;
p_dvb->i_polarisation = VLC_FALSE;
}
else if ((!strncmp( psz_parser_init, "H" ,
else if( (!strncmp( psz_parser_init, "H" ,
psz_parser - psz_parser_init ) ) ||
(!strncmp( psz_parser_init, "h" ,
psz_parser - psz_parser_init ) ) )
{
i_polarisation = 1; //VLC_TRUE;
p_dvb->i_polarisation = VLC_TRUE;
}
else if ((!strncmp( psz_parser_init, "A" ,
else if( (!strncmp( psz_parser_init, "A" ,
psz_parser - psz_parser_init ) ) ||
(!strncmp( psz_parser_init, "a" ,
psz_parser - psz_parser_init ) ) )
{
i_polarisation = 2;
p_dvb->i_polarisation = 2;
}
}
else if( !strncmp( psz_parser, "fec=",
strlen( "fec=" ) ) )
{
i_fec =
p_dvb->i_fec =
(int)strtol( psz_parser + strlen( "fec=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "srate=",
strlen( "srate=" ) ) )
{
u_srate =
p_dvb->u_srate =
(unsigned int)strtol( psz_parser + strlen( "srate=" ),
&psz_parser, 0 );
}
......@@ -245,92 +202,92 @@ int E_(Open) ( vlc_object_t *p_this )
strlen( "disecq" ) ) )
{
psz_parser += strlen("disecq");
b_diseqc = VLC_TRUE;
p_dvb->b_diseqc = VLC_TRUE;
}
else if( !strncmp( psz_parser, "lnb-lof1=",
strlen( "lnb-lof1=" ) ) )
{
u_lnb_lof1 =
p_dvb->u_lnb_lof1 =
(unsigned int)strtol( psz_parser + strlen( "lnb-lof1=" ),
&psz_parser, 0 );
frontend_info.frequency_min = u_lnb_lof1; /* lnb_lof1 */
frontend_info.frequency_min = p_dvb->u_lnb_lof1; /* lnb_lof1 */
}
else if( !strncmp( psz_parser, "lnb-lof2=",
strlen( "lnb-lof2=" ) ) )
{
u_lnb_lof2 =
p_dvb->u_lnb_lof2 =
(unsigned int)strtol( psz_parser + strlen( "lnb-lof2=" ),
&psz_parser, 0 );
frontend_info.frequency_max = u_lnb_lof2; /* in KHz, lnb_lof2 */
frontend_info.frequency_max = p_dvb->u_lnb_lof2; /* in KHz, lnb_lof2 */
}
else if( !strncmp( psz_parser, "lnb-slof=",
strlen( "lnb-slof=" ) ) )
{
u_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=" ) ) )
{
u_device =
p_dvb->u_device =
(unsigned int)strtol( psz_parser + strlen( "device=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "adapter=",
strlen( "adapter=" ) ) )
{
u_adapter =
p_dvb->u_adapter =
(unsigned int)strtol( psz_parser + strlen( "adapter=" ),
&psz_parser, 0 );
}
else if (!strncmp( psz_parser, "modulation=",
else if( !strncmp( psz_parser, "modulation=",
strlen( "modulation=" ) ) )
{
i_modulation = (int)strtol( psz_parser + strlen( "modulation=" ),
p_dvb->i_modulation = (int)strtol( psz_parser + strlen( "modulation=" ),
&psz_parser, 0 );
}
else if (!strncmp( psz_parser, "bandwidth=",
else if( !strncmp( psz_parser, "bandwidth=",
strlen( "bandwidth=" ) ) )
{
i_bandwidth = (int)strtol( psz_parser + strlen( "bandwidth=" ),
p_dvb->i_bandwidth = (int)strtol( psz_parser + strlen( "bandwidth=" ),
&psz_parser, 0 );
}
else if (!strncmp( psz_parser, "guard=",
else if( !strncmp( psz_parser, "guard=",
strlen( "guard=" ) ) )
{
i_guard = (int)strtol( psz_parser + strlen( "guard=" ),
p_dvb->i_guard = (int)strtol( psz_parser + strlen( "guard=" ),
&psz_parser, 0 );
}
else if (!strncmp( psz_parser, "transmission=",
else if( !strncmp( psz_parser, "transmission=",
strlen( "transmission=" ) ) )
{
i_transmission = (int)strtol( psz_parser +
p_dvb->i_transmission = (int)strtol( psz_parser +
strlen( "transmission=" ),&psz_parser, 0 );
}
else if (!strncmp( psz_parser, "hierarchy=",
else if( !strncmp( psz_parser, "hierarchy=",
strlen( "hierarchy=" ) ) )
{
i_hierarchy = (int)strtol( psz_parser +
p_dvb->i_hierarchy = (int)strtol( psz_parser +
strlen( "hierarchy=" ),&psz_parser, 0 );
}
else if (!strncmp( psz_parser, "code-rate-HP=",
else if( !strncmp( psz_parser, "code-rate-HP=",
strlen( "code-rate-HP=" ) ) )
{
i_code_rate_HP = (int)strtol( psz_parser +
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=",
else if( !strncmp( psz_parser, "code-rate-LP=",
strlen( "code-rate-LP=" ) ) )
{
i_code_rate_LP = (int)strtol( psz_parser +
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");
b_probe = VLC_TRUE;
p_dvb->b_probe = VLC_TRUE;
}
if( *psz_parser )
psz_parser++;
......@@ -340,51 +297,163 @@ int E_(Open) ( vlc_object_t *p_this )
}
else
{
msg_Err(p_input, "DVB Input old syntax deprecreated, use vlc -p dvb to see an explantion of the new syntax");
msg_Err(p_input, "DVB Input old syntax deprecreated");
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, p_dvb->u_adapter, p_dvb->u_device) < 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);
/* Validating input values */
if ( ((u_freq) > frontend_info.frequency_max) ||
((u_freq) < frontend_info.frequency_min) )
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 ((u_freq) > frontend_info.frequency_max)
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) )
{
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) )
{
if( (p_dvb->u_freq) > frontend_info.frequency_max )
msg_Err( p_input, "given frequency %u (kHz) > %u (kHz) max. frequency",
u_freq, frontend_info.frequency_max );
p_dvb->u_freq, frontend_info.frequency_max );
else
msg_Err( p_input, "given frequency %u (kHz) < %u (kHz) min.frequency",
u_freq, frontend_info.frequency_min );
msg_Err( p_input, "baling out given frequency outside specification range for this frontend" );
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 );
free( p_dvb );
return -1;
}
#endif
/* Workaround for backwards compatibility */
if (strncmp( p_input->psz_access, "satellite", 9 ) ==0)
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", u_freq );
u_srate *= 1000;
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 ( ((u_srate) > frontend_info.symbol_rate_max) ||
((u_srate) < frontend_info.symbol_rate_min) )
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" );
u_srate = config_GetInt( p_input, "symbol-rate" );
if ( ((u_srate) > frontend_info.symbol_rate_max) ||
((u_srate) < frontend_info.symbol_rate_min) )
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( (i_fec > 9) || (i_fec < 1) )
if( (p_dvb->i_fec > 9) || (p_dvb->i_fec < 1) )
{
msg_Warn( p_input, "invalid FEC, using default one" );
i_fec = config_GetInt( p_input, "fec" );
if( (i_fec > 9) || (i_fec < 1) )
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;
}
}
......@@ -395,112 +464,129 @@ int E_(Open) ( vlc_object_t *p_this )
{
/* DVB-S: satellite and budget cards (nova) */
case FE_QPSK:
fep.frequency = u_freq; /* KHz */
fep.inversion = dvb_DecodeInversion(p_input, i_polarisation);
fep.u.qpsk.symbol_rate = u_srate;
fep.u.qpsk.fec_inner = dvb_DecodeFEC(p_input, i_fec);
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 );
if (ioctl_SetQPSKFrontend (p_input, fep, i_polarisation,
u_lnb_lof1, u_lnb_lof2, u_lnb_slof,
u_adapter, u_device )<0)
if( ioctl_SetQPSKFrontend( p_input, fep, p_dvb->i_polarisation,
p_dvb->u_lnb_lof1, p_dvb->u_lnb_lof2, p_dvb->u_lnb_slof,
p_dvb->u_adapter, p_dvb->u_device ) < 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 = u_freq; /* in Hz */
fep.inversion = dvb_DecodeInversion(p_input, i_polarisation);
fep.u.qam.symbol_rate = u_srate;
fep.u.qam.fec_inner = dvb_DecodeFEC(p_input, i_fec);
fep.u.qam.modulation = dvb_DecodeModulation(p_input, i_modulation);
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 );
if (ioctl_SetQAMFrontend (p_input, fep, u_adapter, u_device )<0)
if( ioctl_SetQAMFrontend( p_input, fep, p_dvb->u_adapter, p_dvb->u_device ) < 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 = u_freq; /* in Hz */
fep.inversion = dvb_DecodeInversion(p_input, i_polarisation);
fep.u.ofdm.bandwidth = dvb_DecodeBandwidth(p_input, i_bandwidth);
fep.u.ofdm.code_rate_HP = dvb_DecodeFEC(p_input, i_code_rate_HP);
fep.u.ofdm.code_rate_LP = dvb_DecodeFEC(p_input, i_code_rate_LP);
fep.u.ofdm.constellation = dvb_DecodeModulation(p_input, i_modulation);
fep.u.ofdm.transmission_mode = dvb_DecodeTransmission(p_input, i_transmission);
fep.u.ofdm.guard_interval = dvb_DecodeGuardInterval(p_input, i_guard);
fep.u.ofdm.hierarchy_information = dvb_DecodeHierarchy(p_input, i_hierarchy);
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 );
if (ioctl_SetOFDMFrontend (p_input, fep,u_adapter, u_device )<0)
if( ioctl_SetOFDMFrontend( p_input, fep, p_dvb->u_adapter, p_dvb->u_device ) < 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_satellite = malloc( sizeof( input_socket_t ) );
p_dvb->p_satellite = malloc( sizeof( input_socket_t ) );
if( p_satellite == NULL )
if( p_dvb->p_satellite == NULL )
{
msg_Err( p_input, "out of memory" );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
p_input->p_access_data = (void *)p_satellite;
/* Open the DVR device */
i_len = sizeof(DVR);
if (snprintf(dvr, sizeof(DVR), DVR, u_adapter, u_device) >= i_len)
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_satellite->i_handle = open( dvr,
/*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
if( (p_dvb->p_satellite->i_handle = open( dvr,
/*O_NONBLOCK | O_LARGEFILE*/0 ) ) == (-1) )
{
# ifdef HAVE_ERRNO_H
msg_Warn( p_input, "cannot open `%s' (%s)", dvr, strerror(errno) );
msg_Warn( p_input, "cannot open `%s' (%s)", dvr, strerror( errno ) );
# else
msg_Warn( p_input, "cannot open `%s'", dvr );
# endif
free( p_satellite );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
msg_Dbg( p_input, "setting filter on PAT" );
/* Set Filter on PAT packet */
if ( ioctl_SetDMXFilter(p_input, 0, &i_fd, 21, u_adapter, u_device ) < 0 )
if( ioctl_SetDMXFilter(p_input, 0, &i_fd, 21, p_dvb->u_adapter, p_dvb->u_device ) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err( p_input, "an error occured when setting filter on PAT (%s)", strerror(errno) );
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_satellite->i_handle );
free( p_satellite );
close( p_dvb->p_satellite->i_handle );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
return -1;
}
if( input_InitStream( p_input, sizeof( stream_ts_data_t ) ) == -1 )
{
msg_Err( p_input, "could not initialize stream structure" );
close( p_satellite->i_handle );
free( p_satellite );
close( p_dvb->p_satellite->i_handle );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
return( -1 );
}
......@@ -524,17 +610,17 @@ int E_(Open) ( vlc_object_t *p_this )
void E_(Close) ( vlc_object_t *p_this )
{
input_thread_t * p_input = (input_thread_t *)p_this;
input_socket_t * p_satellite;
input_dvb_t * p_dvb;
unsigned int i_es_index;
if ( p_input->stream.p_selected_program )
if( p_input->stream.p_selected_program )
{
for ( i_es_index = 1 ;
for( i_es_index = 1 ;
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 )
{
ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd );
}
......@@ -542,8 +628,13 @@ void E_(Close) ( vlc_object_t *p_this )
}
}
p_satellite = (input_socket_t *)p_input;
close( p_satellite->i_handle );
p_dvb = (input_dvb_t *)p_input->p_access_data;
close( p_dvb->p_satellite->i_handle );
free( p_dvb->p_satellite );
close( p_dvb->i_frontend );
free( p_dvb );
}
/*****************************************************************************
......@@ -552,28 +643,22 @@ void E_(Close) ( vlc_object_t *p_this )
static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len )
{
input_socket_t * p_access_data = (input_socket_t *)p_input->p_access_data;
input_dvb_t * p_dvb = (input_dvb_t *)p_input->p_access_data;
ssize_t i_ret;
unsigned int u_adapter = 1;
unsigned int u_device = 0;
unsigned int i;
// Get adapter and device number to use for this dvb card
u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" );
/* if not set, set filters to the PMTs */
for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
{
if ( p_input->stream.pp_programs[i]->pp_es[0]->i_demux_fd == 0 )
if( p_input->stream.pp_programs[i]->pp_es[0]->i_demux_fd == 0 )
{
ioctl_SetDMXFilter(p_input, p_input->stream.pp_programs[i]->pp_es[0]->i_id,
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, u_adapter, u_device );
21, p_dvb->u_adapter, p_dvb->u_device );
}
}
i_ret = read( p_access_data->i_handle, p_buffer, i_len );
i_ret = read( p_dvb->p_satellite->i_handle, p_buffer, i_len );
if( i_ret < 0 )
{
......@@ -603,29 +688,24 @@ static int SatelliteSetArea( input_thread_t * p_input, input_area_t * p_area )
int SatelliteSetProgram( input_thread_t * p_input,
pgrm_descriptor_t * p_new_prg )
{
input_dvb_t * p_dvb = (input_dvb_t *)p_input->p_access_data;
unsigned int i_es_index;
vlc_value_t val;
unsigned int u_adapter = 1;
unsigned int u_device = 0;
unsigned int u_video_type = 1; /* default video type */
unsigned int u_audio_type = 2; /* default audio type */
/* Get adapter and device number to use for this dvb card */
u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" );
if ( p_input->stream.p_selected_program )
if( p_input->stream.p_selected_program )
{
for ( i_es_index = 1 ; /* 0 should be the PMT */
for( i_es_index = 1 ; /* 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)
if( p_es->i_demux_fd > 0 )
{
ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd );
p_es->i_demux_fd = 0;
......@@ -642,25 +722,25 @@ int SatelliteSetProgram( input_thread_t * p_input,
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
case MPEG2_MOTO_VIDEO_ES:
if ( input_SelectES( p_input , p_es ) == 0 )
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_adapter, u_device);
p_dvb->u_adapter, p_dvb->u_device);
u_video_type += 5;
}
break;
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
if ( input_SelectES( p_input , p_es ) == 0 )
if( input_SelectES( p_input , p_es ) == 0 )
{
ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, u_audio_type,
u_adapter, u_device);
p_dvb->u_adapter, p_dvb->u_device);
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, u_adapter, u_device);
ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, 21, p_dvb->u_adapter, p_dvb->u_device);
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;
......
......@@ -80,537 +80,393 @@ struct diseqc_cmd_t switch_cmds[] =
{ { { 0xe0, 0x10, 0x38, 0xff, 0x00, 0x00 }, 4 }, 0 }
};
static int ioctl_CheckFrontend(input_thread_t * p_input, int front);
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,
unsigned int u_adapter, unsigned int u_device)
int ioctl_InfoFrontend( input_thread_t * p_input, struct dvb_frontend_info *info )
{
int front;
int ret;
char frontend[] = FRONTEND;
int i_len;
i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, 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((front = open(frontend,O_RDWR)) < 0)
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_InfoFrontEnd: opening device failed (%s)", strerror(errno));
# else
msg_Err(p_input, "ioctl_InfoFrontEnd: opening device failed");
# endif
return -1;
}
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 ((ret=ioctl(front, FE_GET_INFO, info)) < 0)
if( (i_ret = ioctl( fd_front, FE_GET_INFO, info )) < 0 )
{
close(front);
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl FE_GET_INFO failed (%d) %s", ret, strerror(errno));
msg_Err( p_input, "Getting info from frontend failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err(p_input, "ioctl FE_GET_INFO failed (%d)", ret);
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)
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)" );
msg_Dbg( p_input, " type = QPSK (DVB-S)" );
break;
case FE_QAM:
msg_Dbg(p_input, " type = QAM (DVB-C)" );
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" );
msg_Dbg( p_input, " type = OFDM (DVB-T)" );
break;
case FE_NET:
msg_Dbg(p_input, " type = NETWORK" );
break;
#endif
default:
msg_Err(p_input, " unknown frontend found fe_type_t(%d)", info->type );
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");
close(front);
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, int fd, fe_sec_voltage_t v, struct diseqc_cmd_t **cmd,
fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
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 )
{
int err;
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
if ((err = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF))<0)
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", err, strerror(errno));
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", err);
msg_Err( p_input, "ioclt FE_SET_TONE failed, tone=%s (%d)", SEC_TONE_ON ? "on" : "off", i_ret );
# endif
return err;
return i_ret;
}
if ((err = ioctl(fd, FE_SET_VOLTAGE, v))<0)
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, err, strerror(errno));
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, err);
msg_Err( p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d)", v, i_ret );
# endif
return err;
return i_ret;
}
msleep(15);
while (*cmd)
msleep( 15 );
while( *cmd )
{
msg_Dbg(p_input, "DiseqcSendMsg(): %02x %02x %02x %02x %02x %02x",
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]);
(*cmd)->cmd.msg[4], (*cmd)->cmd.msg[5] );
if ((err = ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &(*cmd)->cmd))<0)
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", err, strerror(errno));
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)", err);
msg_Err( p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d)", i_ret );
# endif
return err;
return i_ret;
}
msleep((*cmd)->wait);
msleep( (*cmd)->wait );
cmd++;
}
msleep( 15 );
msleep(15);
if ((err = ioctl(fd, FE_DISEQC_SEND_BURST, b))<0)
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, err, strerror(errno));
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, err);
msg_Err( p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d)", b, i_ret );
# endif
return err;
return i_ret;
}
msleep(15);
msleep( 15 );
if ((err = ioctl(fd, FE_SET_TONE, t))<0)
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, err, strerror(errno));
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, err);
msg_Err( p_input, "ioctl FE_SET_TONE failed, tone=%d (%d)", t, i_ret );
# endif
return err;
return i_ret;
}
return err;
return i_ret;
}
/* QPSK only */
int ioctl_SetupSwitch (input_thread_t *p_input, int frontend_fd, int switch_pos,
int voltage_18, int hiband)
int ioctl_SetupSwitch( input_thread_t *p_input, int switch_pos,
int voltage_18, int hiband )
{
int ret;
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, "ioctl_SetupSwitch: switch pos %i, %sV, %sband",
switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo");
msg_Dbg(p_input, "ioctl_SetupSwitch: index %i", i);
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))))
if( (i < 0) || (i >= (int)(sizeof(switch_cmds)/sizeof(struct diseqc_cmd_t))) )
return -EINVAL;
cmd[0] = &switch_cmds[i];
if ((ret = ioctl_DiseqcSendMsg (p_input, frontend_fd,
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)
(i/4) % 2 ? SEC_MINI_B : SEC_MINI_A)) < 0 )
{
msg_Err(p_input, "ioctl_DiseqcSendMsg() failed (%d)", ret);
return ret;
return i_ret;
}
return ret;
return i_ret;
}
/*****************************************************************************
* ioctl_SetQPSKFrontend : controls the FE device
*****************************************************************************/
int ioctl_SetQPSKFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation,
unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
unsigned int u_adapter, unsigned int u_device )
int ioctl_SetQPSKFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep )
{
int ret;
int front;
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int hiband;
char frontend[] = FRONTEND;
int i_len;
i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{
msg_Err(p_input, "DVB-S: FrontEnd snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0';
}
/* Open the frontend device */
msg_Dbg(p_input, "DVB-S: Opening frontend %s", frontend);
if(( front = open(frontend,O_RDWR)) < 0)
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "DVB-S: failed to open frontend (%s)", strerror(errno));
# else
msg_Err(p_input, "DVB-S: failed to open frontend");
# endif
return -1;
}
int i_ret;
/* Set the frequency of the transponder, taking into account the
local frequencies of the LNB */
hiband = (fep.frequency >= u_lnb_slof);
hiband = (fep.frequency >= p_dvb->u_lnb_slof);
if ((ret=ioctl_SetupSwitch (p_input, front, 0, b_polarisation, hiband))<0)
if( (i_ret=ioctl_SetupSwitch (p_input, 0, p_dvb->b_polarisation, hiband)) < 0 )
{
msg_Err(p_input, "DVB-S: Setup frontend switch failed (%d)", ret);
msg_Err( p_input, "DVB-S: Setup frontend switch failed (%d)", i_ret );
return -1;
}
if (hiband)
fep.frequency -= u_lnb_lof2;
if( hiband )
fep.frequency -= p_dvb->u_lnb_lof2;
else
fep.frequency -= u_lnb_lof1;
fep.frequency -= p_dvb->u_lnb_lof1;
/* Now send it all to the frontend device */
if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
if( (i_ret=ioctl(fd_front, FE_SET_FRONTEND, &fep)) < 0 )
{
close(front);
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "DVB-S: setting frontend failed (%d) %s", ret, strerror(errno));
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)", ret);
msg_Err( p_input, "DVB-S: setting frontend failed (%d)", i_ret );
# endif
return -1;
}
ret = ioctl_CheckFrontend(p_input, front);
i_ret = ioctl_CheckFrontend( p_input, FE_QPSK );
/* Fixme: Return this instead of closing it.
Close front end device */
close(front);
return ret;
return i_ret;
}
int ioctl_SetOFDMFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
unsigned int u_adapter, unsigned int u_device )
int ioctl_SetOFDMFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep )
{
int ret;
int front;
char frontend[] = FRONTEND;
int i_len;
i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{
msg_Err(p_input, "DVB-T FrontEnd snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0';
}
/* Open the frontend device */
msg_Dbg(p_input, "DVB-T: Opening frontend %s", frontend);
if(( front = open(frontend,O_RDWR)) < 0)
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "DVB-T: failed to open frontend (%s)", strerror(errno));
# else
msg_Err(p_input, "DVB-T: failed to open frontend");
# endif
return -1;
}
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 ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
if( (i_ret=ioctl(fd_front, FE_SET_FRONTEND, &fep)) < 0 )
{
close(front);
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "DVB-T: setting frontend failed (%d) %s", ret, strerror(errno));
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)", ret);
msg_Err( p_input, "DVB-T: setting frontend failed (%d)", i_ret );
# endif
return -1;
}
ret = ioctl_CheckFrontend(p_input, front);
i_ret = ioctl_CheckFrontend( p_input, FE_OFDM );
/* Fixme: Return this instead of closing it.
Close front end device */
close(front);
return ret;
return i_ret;
}
int ioctl_SetQAMFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
unsigned int u_adapter, unsigned int u_device )
int ioctl_SetQAMFrontend( input_thread_t * p_input, struct dvb_frontend_parameters fep )
{
int ret;
int front;
char frontend[] = FRONTEND;
int i_len;
i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{
msg_Err(p_input, "DVB-C: FrontEnd snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0';
}
/* Open the frontend device */
msg_Dbg(p_input, "DVB-C: Opening frontend %s", frontend);
if(( front = open(frontend,O_RDWR)) < 0)
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "DVB-C: failed to open frontend (%s)", strerror(errno));
# else
msg_Err(p_input, "DVB-C: failed to open frontend");
# endif
return -1;
}
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: FEC Inner %d", fep.u.qam.fec_inner);
msg_Dbg(p_input, "DVB-C: Modulation %d", fep.u.qam.modulation);
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 ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
if( (i_ret=ioctl(fd_front, FE_SET_FRONTEND, &fep)) < 0 )
{
close(front);
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "DVB-C: tuning channel failed (frontend returned %d:%s)", ret, strerror(errno));
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)", ret);
msg_Err( p_input, "DVB-C: tuning channel failed (frontend returned %d)", i_ret );
# endif
return -1;
}
/* Check Status of frontend */
ret = ioctl_CheckFrontend(p_input, front);
i_ret = ioctl_CheckFrontend( p_input, FE_QAM );
/* Fixme: Return this instead of closing it.
Close front end device */
close(front);
return ret;
return i_ret;
}
/******************************************************************
* Check completion of the frontend control sequence
******************************************************************/
static int ioctl_CheckFrontend(input_thread_t * p_input, int front)
static int ioctl_CheckFrontend( input_thread_t * p_input, fe_type_t type )
{
int i;
int ret;
struct pollfd pfd[1];
struct dvb_frontend_event event;
/* poll for frontend event to check if tuning worked */
pfd[0].fd = front;
pfd[0].events = POLLIN;
#if 1
for (i=0; i<3; i++)
input_dvb_t *p_dvb = (input_dvb_t *)p_input->p_access_data;
int fd_front = p_dvb->i_frontend;
int i_ret;
while( 1 )
{
int32_t value;
fe_status_t status;
if ((ret=ioctl(front, FE_READ_STATUS, &status))<0)
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", ret, strerror(errno));
msg_Err( p_input, "reading frontend status failed (%d) %s", i_ret, strerror( errno ) );
# else
msg_Err(p_input, "reading frontend status failed (%d)", ret);
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_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_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 fec");
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_SYNC ) /* found sync bytes */
msg_Dbg( p_input, "check frontend ... has sync" );
if (status & FE_HAS_LOCK) /* everything's working... */
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);
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 */
if( status & FE_TIMEDOUT ) /* no lock within the last ~2 seconds */
{
msg_Dbg(p_input, "check frontend ... tuning status == 0x%02x!!! ..."
"tuning failed", status);
msg_Err(p_input, "check frontend ... timed out");
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)
if( status & FE_REINIT )
{
/* frontend was reinitialized, */
/* application is recommned to reset */
/* DiSEqC, tone and parameters */
msg_Dbg(p_input, "DVB-S: tuning status == 0x%02x!!! ..."
"tuning failed", status);
msg_Err(p_input, "check frontend ... resend frontend parameters");
return -1;
}
usleep( 500000 );
}
#else
if (poll(pfd,1,3000))
{
if (pfd[0].revents & POLLIN)
switch( type )
{
if ( (ret=ioctl(front, FE_GET_EVENT, &event)) < 0)
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "check frontend ... error occured (%d) %s", ret, strerror(errno));
# else
msg_Err(p_input, "check frontend ... error occured (%d)", ret);
# endif
return -5;
}
switch(event.status)
{
case FE_HAS_SIGNAL: /* found something above the noise level */
msg_Dbg(p_input, "check frontend ... has signal");
case FE_OFDM:
msg_Dbg( p_input, "DVB-T: tuning status == 0x%02x", status );
break;
case FE_HAS_CARRIER: /* found a DVB signal */
msg_Dbg(p_input, "check frontend ... has carrier");
case FE_QPSK:
msg_Dbg( p_input, "DVB-S: tuning status == 0x%02x", status );
break;
case FE_HAS_VITERBI: /* FEC is stable */
msg_Dbg(p_input, "check frontend ... has stable fec");
case FE_QAM:
msg_Dbg( p_input, "DVB-C: tuning status == 0x%02x", status );
break;
case FE_HAS_SYNC: /* found sync bytes */
msg_Dbg(p_input, "check frontend ... has sync");
default:
break;
case FE_HAS_LOCK: /* everything's working... */
msg_Dbg(p_input, "check frontend ... has lock");
return 0;
case FE_TIMEDOUT: /* no lock within the last ~2 seconds */
msg_Err(p_input, "check frontend ... timed out");
return -2;
case FE_REINIT: /* frontend was reinitialized, */
/* application is recommned to reset */
/* DiSEqC, tone and parameters */
msg_Err(p_input, "check frontend ... resend frontend parameters");
return -1;
}
}
else
{
/* should come here */
msg_Err(p_input, "check frontend ... no event occured");
return -3;
}
msg_Err( p_input, "check frontend ... resend frontend parameters" );
msg_Err( p_input, "check frontend ... tuning failed" );
return -1;
}
else
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "check frontend ... timeout when polling for event (%s)", strerror(errno));
# else
msg_Err(p_input, "check frontend ... timeout when polling for event ");
# endif
return -4;
/* 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 );
}
#endif
return -1;
}
......@@ -618,9 +474,9 @@ static int ioctl_CheckFrontend(input_thread_t * p_input, int front)
/*****************************************************************************
* 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,
unsigned int u_adapter, unsigned int u_device )
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;
......@@ -628,19 +484,19 @@ int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_
/* We first open the device */
i_len = sizeof(DMX);
if (snprintf( dmx, sizeof(DMX), DMX, u_adapter, u_device) >= i_len)
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" );
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)
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, "ioctl_SetDMXFilter: opening device failed (%s)", strerror(errno));
msg_Err( p_input, "Demux set filter: opening device failed (%s)", strerror( errno ) );
# else
msg_Err(p_input, "ioctl_SetDMXFilter: opening device failed");
msg_Err( p_input, "Demux set filter: opening device failed" );
# endif
return -1;
}
......@@ -649,110 +505,110 @@ int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_
s_filter_params.pid = i_pid;
s_filter_params.input = DMX_IN_FRONTEND;
s_filter_params.output = DMX_OUT_TS_TAP;
switch ( i_type )
switch( i_type )
{ /* First device */
case 1:
msg_Dbg(p_input, "ioctl_SetDMXFilter: DMX_PES_VIDEO0 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_AUDIO0 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_TELETEXT0 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE0 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_PCR0 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_VIDEO1 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_AUDIO1 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_TELETEXT1 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE1 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_PCR1 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_VIDEO2 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_AUDIO2 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_TELETEXT2 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE2 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_PCR2 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_VIDEO3 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_AUDIO3 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_TELETEXT3 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_SUBTITLE3 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_PCR3 for PMT %d", i_pid);
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, "ioctl_SetDMXFilter: DMX_PES_OTHER for PMT %d", i_pid);
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 );
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)
if( (result = ioctl( *pi_fd, DMX_SET_PES_FILTER, &s_filter_params )) < 0 )
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_SetDMXFilter: ioctl failed with %d (%s)",result, strerror(errno));
msg_Err( p_input, "Demux set filter ioctl failed with %d (%s)", result, strerror( errno ) );
# else
msg_Err(p_input, "ioctl_SetDMXFilter: ioctl failed with %d",result);
msg_Err( p_input, "Demux set filter ioctl failed with %d", result );
# endif
return -1;
}
......@@ -762,32 +618,32 @@ int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int * pi_fd , int i_
/*****************************************************************************
* ioctl_UnsetDMXFilter : removes a filter
*****************************************************************************/
int ioctl_UnsetDMXFilter(input_thread_t * p_input, int pi_fd)
int ioctl_UnsetDMXFilter( input_thread_t * p_input, int pi_fd )
{
int ret;
int i_ret;
if ((ret=ioctl( pi_fd, DMX_STOP))<0)
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, ret, strerror(errno));
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, ret);
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);
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 dvb_DecodeBandwidth( input_thread_t * p_input, int bandwidth )
{
fe_bandwidth_t fe_bandwidth = 0;
switch (bandwidth)
switch( bandwidth )
{
case 0:
fe_bandwidth = BANDWIDTH_AUTO;
......@@ -802,15 +658,14 @@ fe_bandwidth_t dvb_DecodeBandwidth(input_thread_t * p_input, int bandwidth)
fe_bandwidth = BANDWIDTH_8_MHZ;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has bandwidth not set, using auto");
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 dvb_DecodeFEC( input_thread_t * p_input, int fec )
{
fe_code_rate_t fe_fec = FEC_NONE;
......@@ -846,13 +701,13 @@ fe_code_rate_t dvb_DecodeFEC(input_thread_t * p_input, int fec)
default:
/* cannot happen */
fe_fec = FEC_NONE;
msg_Err( p_input, "argument has invalid FEC (%d)", fec);
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 dvb_DecodeModulation( input_thread_t * p_input, int modulation )
{
fe_modulation_t fe_modulation = 0;
......@@ -880,14 +735,14 @@ fe_modulation_t dvb_DecodeModulation(input_thread_t * p_input, int modulation)
fe_modulation = QAM_256;
break;
default:
msg_Dbg( p_input, "terrestrial/cable dvb has constellation/modulation not set, using auto");
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 dvb_DecodeTransmission( input_thread_t * p_input, int transmission )
{
fe_transmit_mode_t fe_transmission = 0;
......@@ -903,14 +758,14 @@ fe_transmit_mode_t dvb_DecodeTransmission(input_thread_t * p_input, int transmis
fe_transmission = TRANSMISSION_MODE_8K;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has transmission mode not set, using auto");
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 dvb_DecodeGuardInterval( input_thread_t * p_input, int guard )
{
fe_guard_interval_t fe_guard = 0;
......@@ -932,18 +787,18 @@ fe_guard_interval_t dvb_DecodeGuardInterval(input_thread_t * p_input, int guard)
fe_guard = GUARD_INTERVAL_1_32;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has guard interval not set, using auto");
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 dvb_DecodeHierarchy( input_thread_t * p_input, int hierarchy )
{
fe_hierarchy_t fe_hierarchy = 0;
switch (hierarchy)
switch( hierarchy )
{
case -1:
fe_hierarchy = HIERARCHY_NONE;
......@@ -961,18 +816,18 @@ fe_hierarchy_t dvb_DecodeHierarchy(input_thread_t * p_input, int hierarchy)
fe_hierarchy = HIERARCHY_4;
break;
default:
msg_Dbg( p_input, "terrestrial dvb has hierarchy not set, using auto");
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 dvb_DecodeInversion( input_thread_t * p_input, int inversion )
{
fe_spectral_inversion_t fe_inversion=0;
switch (inversion)
switch( inversion )
{
case 0:
fe_inversion = INVERSION_OFF;
......@@ -984,7 +839,7 @@ fe_spectral_inversion_t dvb_DecodeInversion(input_thread_t * p_input, int invers
fe_inversion = INVERSION_AUTO;
break;
default:
msg_Dbg( p_input, "dvb has inversion/polarisation not set, using auto");
msg_Dbg( p_input, "dvb has inversion/polarisation not set, using auto" );
fe_inversion = INVERSION_AUTO;
break;
}
......
......@@ -30,28 +30,54 @@
#define FRONTEND "/dev/dvb/adapter%d/frontend%d"
#define DVR "/dev/dvb/adapter%d/dvr%d"
/*****************************************************************************
* DVB input data structure
*****************************************************************************/
typedef struct
{
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;
input_socket_t * p_satellite;
} input_dvb_t;
/*****************************************************************************
* Prototypes
*****************************************************************************/
int ioctl_SetQPSKFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation,
unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
unsigned int u_adapter, unsigned int u_device );
int ioctl_SetOFDMFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
unsigned int u_adapter, unsigned int u_device );
int ioctl_SetQAMFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
unsigned int u_adapter, unsigned int u_device );
int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int *pi_fd, int i_type, unsigned int u_adapter, unsigned int u_device );
int ioctl_UnsetDMXFilter(input_thread_t * p_input, int pi_fd);
int ioctl_InfoFrontend(input_thread_t * p_input, struct dvb_frontend_info *info, unsigned int u_adapter, unsigned int u_device );
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 );
/*****************************************************************************
* dvb argument helper functions
*****************************************************************************/
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);
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);
......@@ -47,7 +47,7 @@ void E_(Close) ( vlc_object_t * );
#define DEVICE_TEXT N_("Device number to use on adapter")
#define DEVICE_LONGTEXT ""
#define FREQ_TEXT N_("Satellite transponder frequency in kHz for DVB-S and in Hz for DVB-C/T")
#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")
......@@ -99,12 +99,14 @@ void E_(Close) ( vlc_object_t * );
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,
......@@ -116,7 +118,7 @@ vlc_module_begin();
VLC_TRUE );
add_integer( "lnb-slof", 11700000, NULL, LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT,
VLC_TRUE );
add_bool( "probe", 0, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_FALSE );
/* 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,
......@@ -130,12 +132,15 @@ vlc_module_begin();
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( "dvb" );
add_shortcut( "satellite" );
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