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

Tuning succeeds, but have no audio yet. Major cleanup of code.

parent f853698b
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
* *
* Authors: Johan Bilien <jobi@via.ecp.fr> * Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <saman@natlab.research.philips.com> * Jean-Paul Saman <saman@natlab.research.philips.com>
* Christopher Ross <ross@natlab.research.philips.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -40,8 +39,11 @@ ...@@ -40,8 +39,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <errno.h> #ifdef HAVE_ERRNO_H
# include <string.h>
# include <errno.h>
#endif
#ifdef STRNCASECMP_IN_STRINGS_H #ifdef STRNCASECMP_IN_STRINGS_H
# include <strings.h> # include <strings.h>
...@@ -84,7 +86,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -84,7 +86,7 @@ int E_(Open) ( vlc_object_t *p_this )
int i_fec = 0; int i_fec = 0;
fe_code_rate_t fe_fec = FEC_NONE; fe_code_rate_t fe_fec = FEC_NONE;
vlc_bool_t b_diseqc; vlc_bool_t b_diseqc;
vlc_bool_t b_no_probe; vlc_bool_t b_probe;
int i_lnb_lof1; int i_lnb_lof1;
int i_lnb_lof2; int i_lnb_lof2;
int i_lnb_slof; int i_lnb_slof;
...@@ -100,20 +102,15 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -100,20 +102,15 @@ int E_(Open) ( vlc_object_t *p_this )
return( -1 ); return( -1 );
} }
p_input->pf_read = SatelliteRead;
p_input->pf_set_program = SatelliteSetProgram;
p_input->pf_set_area = SatelliteSetArea;
p_input->pf_seek = SatelliteSeek;
// Get adapter and device number to use for this dvb card // Get adapter and device number to use for this dvb card
u_adapter = config_GetInt( p_input, "adapter" ); u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" ); u_device = config_GetInt( p_input, "device" );
/* Determine frontend device information and capabilities */ /* Determine frontend device information and capabilities */
b_no_probe = config_GetInt( p_input, "no-probe" ); b_probe = config_GetInt( p_input, "probe" );
if (!b_no_probe) if (b_probe)
{ {
if ( ioctl_InfoFrontend(&frontend_info, u_adapter, u_device) < 0 ) 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, "(access) cannot determine frontend info" );
return -1; return -1;
...@@ -128,14 +125,14 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -128,14 +125,14 @@ int E_(Open) ( vlc_object_t *p_this )
{ {
int i_len; int i_len;
msg_Dbg( p_input, "Using default values for frontend info" ); msg_Dbg( p_input, "using default values for frontend info" );
i_len = sizeof(FRONTEND); i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len) if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{ {
printf( "error: snprintf() truncated string for FRONTEND" ); msg_Err( p_input, "snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0'; frontend[sizeof(FRONTEND)] = '\0';
} }
frontend_info.name = frontend; strncpy(frontend_info.name, frontend, 128);
frontend_info.type = FE_QPSK; frontend_info.type = FE_QPSK;
frontend_info.frequency_max = 12999; frontend_info.frequency_max = 12999;
frontend_info.frequency_min = 10000; frontend_info.frequency_min = 10000;
...@@ -144,7 +141,13 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -144,7 +141,13 @@ int E_(Open) ( vlc_object_t *p_this )
/* b_polarisation */ /* b_polarisation */
} }
u_freq = (int)strtol( psz_parser, &psz_next, 10 ); /* 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;
u_freq = (unsigned int)strtol( psz_parser, &psz_next, 10 );
if( *psz_next ) if( *psz_next )
{ {
psz_parser = psz_next + 1; psz_parser = psz_next + 1;
...@@ -156,7 +159,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -156,7 +159,7 @@ int E_(Open) ( vlc_object_t *p_this )
if( *psz_next ) if( *psz_next )
{ {
psz_parser = psz_next + 1; psz_parser = psz_next + 1;
u_srate = (int)strtol( psz_parser, &psz_next, 10 ); u_srate = (unsigned int)strtol( psz_parser, &psz_next, 10 );
} }
} }
} }
...@@ -187,7 +190,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -187,7 +190,7 @@ int E_(Open) ( vlc_object_t *p_this )
} }
} }
if( b_polarisation && b_polarisation != 1 ) if( b_polarisation && (b_polarisation != 1) )
{ {
msg_Warn( p_input, "invalid polarization, using default one" ); msg_Warn( p_input, "invalid polarization, using default one" );
b_polarisation = config_GetInt( p_input, "polarization" ); b_polarisation = config_GetInt( p_input, "polarization" );
...@@ -198,11 +201,11 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -198,11 +201,11 @@ int E_(Open) ( vlc_object_t *p_this )
} }
} }
if( (i_fec > 7) || (i_fec < 1) ) if( (i_fec > 9) || (i_fec < 1) )
{ {
msg_Warn( p_input, "invalid FEC, using default one" ); msg_Warn( p_input, "invalid FEC, using default one" );
i_fec = config_GetInt( p_input, "fec" ); i_fec = config_GetInt( p_input, "fec" );
if( (i_fec > 7) || (i_fec < 1) ) if( (i_fec > 9) || (i_fec < 1) )
{ {
msg_Err( p_input, "invalid default FEC" ); msg_Err( p_input, "invalid default FEC" );
return -1; return -1;
...@@ -241,6 +244,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -241,6 +244,7 @@ int E_(Open) ( vlc_object_t *p_this )
default: default:
/* cannot happen */ /* cannot happen */
fe_fec = FEC_NONE; fe_fec = FEC_NONE;
msg_Err( p_input, "invalid FEC (unknown)" );
break; break;
} }
...@@ -279,7 +283,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -279,7 +283,7 @@ int E_(Open) ( vlc_object_t *p_this )
i_len = sizeof(DVR); i_len = sizeof(DVR);
if (snprintf(dvr, sizeof(DVR), DVR, u_adapter, u_device) >= i_len) if (snprintf(dvr, sizeof(DVR), DVR, u_adapter, u_device) >= i_len)
{ {
msg_Err( p_input, "error: snprintf() truncated string for DVR" ); msg_Err( p_input, "snprintf() truncated string for DVR" );
dvr[sizeof(DVR)] = '\0'; dvr[sizeof(DVR)] = '\0';
} }
msg_Dbg( p_input, "opening DVR device '%s'", dvr ); msg_Dbg( p_input, "opening DVR device '%s'", dvr );
...@@ -287,7 +291,11 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -287,7 +291,11 @@ int E_(Open) ( vlc_object_t *p_this )
if( (p_satellite->i_handle = open( dvr, if( (p_satellite->i_handle = open( dvr,
/*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) ) /*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_satellite );
return -1; return -1;
} }
...@@ -299,13 +307,10 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -299,13 +307,10 @@ int E_(Open) ( vlc_object_t *p_this )
i_lnb_slof = config_GetInt( p_input, "lnb-slof" ); i_lnb_slof = config_GetInt( p_input, "lnb-slof" );
/* Initialize the Satellite Card */ /* Initialize the Satellite Card */
msg_Dbg( p_input, "initializing Sat Card with Freq: %d, Pol: %d, " msg_Dbg( p_input, "initializing Sat Card with Freq: %u, Pol: %d, "
"FEC: %d, Srate: %d", u_freq, b_polarisation, fe_fec, u_srate ); "FEC: %d, Srate: %u", u_freq, b_polarisation, fe_fec, u_srate );
msg_Dbg( p_input, "initializing frontend device" ); switch (ioctl_SetQPSKFrontend (p_input, fep, b_polarisation, u_adapter, u_device ))
// switch (ioctl_SetQPSKFrontend ( u_freq * 1000, i_srate* 1000, fe_fec,
// i_lnb_lof1 * 1000, i_lnb_lof2 * 1000, i_lnb_slof * 1000))
switch (ioctl_SetQPSKFrontend ( fep, b_polarisation, u_adapter, u_device ))
{ {
case -2: case -2:
msg_Err( p_input, "frontend returned an unexpected event" ); msg_Err( p_input, "frontend returned an unexpected event" );
...@@ -336,18 +341,20 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -336,18 +341,20 @@ int E_(Open) ( vlc_object_t *p_this )
break; break;
} }
msg_Dbg( p_input, "setting filter on PAT\n" ); msg_Dbg( p_input, "setting filter on PAT" );
if ( ioctl_SetDMXFilter( 0, &i_fd, 3, u_adapter, u_device ) < 0 ) if ( ioctl_SetDMXFilter(p_input, 0, &i_fd, 3, u_adapter, u_device ) < 0 )
{ {
# 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" ); msg_Err( p_input, "an error occured when setting filter on PAT" );
# endif
close( p_satellite->i_handle ); close( p_satellite->i_handle );
free( p_satellite ); free( p_satellite );
return -1; return -1;
} }
msg_Dbg( p_input, "@@@ Initialising input stream\n" );
if( input_InitStream( p_input, sizeof( stream_ts_data_t ) ) == -1 ) if( input_InitStream( p_input, sizeof( stream_ts_data_t ) ) == -1 )
{ {
msg_Err( p_input, "could not initialize stream structure" ); msg_Err( p_input, "could not initialize stream structure" );
...@@ -367,7 +374,6 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -367,7 +374,6 @@ int E_(Open) ( vlc_object_t *p_this )
p_input->i_mtu = SATELLITE_READ_ONCE * TS_PACKET_SIZE; p_input->i_mtu = SATELLITE_READ_ONCE * TS_PACKET_SIZE;
p_input->stream.i_method = INPUT_METHOD_SATELLITE; p_input->stream.i_method = INPUT_METHOD_SATELLITE;
msg_Dbg( p_input, "@@@ Leaving E_(Open)\n" );
return 0; return 0;
} }
...@@ -389,7 +395,7 @@ void E_(Close) ( vlc_object_t *p_this ) ...@@ -389,7 +395,7 @@ void E_(Close) ( vlc_object_t *p_this )
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index] #define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
if ( p_es->p_decoder_fifo ) if ( p_es->p_decoder_fifo )
{ {
ioctl_UnsetDMXFilter( p_es->i_demux_fd ); ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd );
} }
#undef p_es #undef p_es
} }
...@@ -409,11 +415,8 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer, ...@@ -409,11 +415,8 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
ssize_t i_ret; ssize_t i_ret;
unsigned int u_adapter = 1; unsigned int u_adapter = 1;
unsigned int u_device = 0; unsigned int u_device = 0;
unsigned int i; unsigned int i;
msg_Dbg( p_input, "@@@ SatelliteRead seeking for %d program\n", p_input->stream.i_pgrm_number );
// Get adapter and device number to use for this dvb card // Get adapter and device number to use for this dvb card
u_adapter = config_GetInt( p_input, "adapter" ); u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" ); u_device = config_GetInt( p_input, "device" );
...@@ -421,15 +424,9 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer, ...@@ -421,15 +424,9 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
/* if not set, set filters to the PMTs */ /* if not set, set filters to the PMTs */
for( i = 0; i < p_input->stream.i_pgrm_number; i++ ) for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
{ {
msg_Dbg( p_input, "@@@ trying to set filter on pmt pid %d",
p_input->stream.pp_programs[i]->pp_es[0]->i_id );
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 )
{ {
msg_Dbg( p_input, "setting filter on pmt pid %d", 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_id );
ioctl_SetDMXFilter( p_input->stream.pp_programs[i]->pp_es[0]->i_id,
&p_input->stream.pp_programs[i]->pp_es[0]->i_demux_fd, &p_input->stream.pp_programs[i]->pp_es[0]->i_demux_fd,
3, u_adapter, u_device ); 3, u_adapter, u_device );
} }
...@@ -446,8 +443,6 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer, ...@@ -446,8 +443,6 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
# endif # endif
} }
msg_Dbg( p_input, "@@@ Searched all, returning %d\n", i_ret );
return i_ret; return i_ret;
} }
...@@ -471,8 +466,6 @@ int SatelliteSetProgram( input_thread_t * p_input, ...@@ -471,8 +466,6 @@ int SatelliteSetProgram( input_thread_t * p_input,
unsigned int u_adapter = 1; unsigned int u_adapter = 1;
unsigned int u_device = 0; unsigned int u_device = 0;
msg_Dbg( p_input, "@@@ SatelliteSetProgram enter\n" );
// Get adapter and device number to use for this dvb card // Get adapter and device number to use for this dvb card
u_adapter = config_GetInt( p_input, "adapter" ); u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" ); u_device = config_GetInt( p_input, "device" );
...@@ -490,7 +483,7 @@ int SatelliteSetProgram( input_thread_t * p_input, ...@@ -490,7 +483,7 @@ int SatelliteSetProgram( input_thread_t * p_input,
} }
if ( p_es->i_demux_fd ) if ( p_es->i_demux_fd )
{ {
ioctl_UnsetDMXFilter( p_es->i_demux_fd ); ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd );
p_es->i_demux_fd = 0; p_es->i_demux_fd = 0;
} }
#undef p_es #undef p_es
...@@ -506,19 +499,19 @@ int SatelliteSetProgram( input_thread_t * p_input, ...@@ -506,19 +499,19 @@ int SatelliteSetProgram( input_thread_t * p_input,
case MPEG2_VIDEO_ES: case MPEG2_VIDEO_ES:
if ( input_SelectES( p_input , p_es ) == 0 ) if ( input_SelectES( p_input , p_es ) == 0 )
{ {
ioctl_SetDMXFilter( p_es->i_id, &p_es->i_demux_fd, 1, u_adapter, u_device); ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, 1, u_adapter, u_device);
} }
break; break;
case MPEG1_AUDIO_ES: case MPEG1_AUDIO_ES:
case MPEG2_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_es->i_id, &p_es->i_demux_fd, 2, u_adapter, u_device); ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, 2, u_adapter, u_device);
input_SelectES( p_input , p_es ); input_SelectES( p_input , p_es );
} }
break; break;
default: default:
ioctl_SetDMXFilter( p_es->i_id, &p_es->i_demux_fd, 3, u_adapter, u_device); ioctl_SetDMXFilter(p_input, p_es->i_id, &p_es->i_demux_fd, 3, u_adapter, u_device);
input_SelectES( p_input , p_es ); input_SelectES( p_input , p_es );
break; break;
#undef p_es #undef p_es
...@@ -527,7 +520,6 @@ int SatelliteSetProgram( input_thread_t * p_input, ...@@ -527,7 +520,6 @@ int SatelliteSetProgram( input_thread_t * p_input,
p_input->stream.p_selected_program = p_new_prg; p_input->stream.p_selected_program = p_new_prg;
msg_Dbg( p_input, "@@@ SatelliteSetProgram exit\n" );
return 0; return 0;
} }
......
...@@ -24,11 +24,15 @@ ...@@ -24,11 +24,15 @@
*****************************************************************************/ *****************************************************************************/
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #ifdef HAVE_ERRNO_H
#include <errno.h> # include <string.h>
# include <errno.h>
#endif
#ifdef HAVE_INTTYPES_H #ifdef HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */ # include <inttypes.h> /* int16_t .. */
#endif #endif
...@@ -49,12 +53,39 @@ ...@@ -49,12 +53,39 @@
#include "dvb.h" #include "dvb.h"
static int ioctl_CheckQPSK( int ); 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_CheckQPSK(input_thread_t * p_input, int front);
/***************************************************************************** /*****************************************************************************
* ioctl_FrontendControl : commands the SEC device * ioctl_FrontendControl : commands the SEC device
*****************************************************************************/ *****************************************************************************/
int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned int u_adapter, unsigned int u_device) int ioctl_FrontendControl(input_thread_t * p_input, int freq, int pol, int lnb_slof,
int diseqc, unsigned int u_adapter, unsigned int u_device)
{ {
struct dvb_diseqc_master_cmd cmd; struct dvb_diseqc_master_cmd cmd;
fe_sec_tone_mode_t tone; fe_sec_tone_mode_t tone;
...@@ -63,17 +94,21 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned ...@@ -63,17 +94,21 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned
char front[] = FRONTEND; char front[] = FRONTEND;
int i_len; int i_len;
printf("ioclt_FrontEndControl: enter\n");
i_len = sizeof(FRONTEND); i_len = sizeof(FRONTEND);
if (snprintf(front, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len) if (snprintf(front, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{ {
printf( "error: snprintf() truncated string for FRONTEND" ); msg_Err(p_input, "snprintf() truncated string for FRONTEND" );
front[sizeof(FRONTEND)] = '\0'; front[sizeof(FRONTEND)] = '\0';
} }
printf("ioclt_FrontEndControl: Opening frontend %s\n",front); msg_Dbg(p_input, "Opening frontend %s",front);
if((frontend = open(front,O_RDWR)) < 0) if((frontend = open(front,O_RDWR)) < 0)
{ {
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_FrontEndControl: Opening frontend failed (%s)",strerror(errno));
# else
msg_Err(p_input, "ioctl_FrontEndControl: Opening frontend failed");
# endif
return -1; return -1;
} }
...@@ -94,18 +129,27 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned ...@@ -94,18 +129,27 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned
cmd.msg_len = 4; cmd.msg_len = 4;
/* Reset everything before sending. */ /* Reset everything before sending. */
#define CHECK_IOCTL(X) if(X<0) \ #ifdef HAVE_ERRNO_H
# define CHECK_IOCTL(X) if(X<0) \
{ \ { \
msg_Err( p_input, "InfoFrontend: ioctl failed (%s)", strerror(errno)); \
close(frontend); \ close(frontend); \
return -1; \ return -1; \
} }
#else
# define CHECK_IOCTL(X) if(X<0) \
{ \
msg_Err( p_input, "InfoFrontend: ioctl failed"); \
close(frontend); \
return -1; \
}
#endif
CHECK_IOCTL(ioctl(frontend, FE_SET_TONE, SEC_TONE_OFF)); CHECK_IOCTL(ioctl(frontend, FE_SET_TONE, SEC_TONE_OFF));
CHECK_IOCTL(ioctl(frontend, FE_SET_VOLTAGE, voltage)); CHECK_IOCTL(ioctl(frontend, FE_SET_VOLTAGE, voltage));
msleep(15); msleep(15);
/* Send the data to the SEC device to prepare the LNB for tuning */ /* Send the data to the SEC device to prepare the LNB for tuning */
/*intf_Msg("Sec: Sending data\n");*/
CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd)); CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd));
msleep(15); msleep(15);
CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_BURST, &cmd)); CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_BURST, &cmd));
...@@ -114,41 +158,50 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned ...@@ -114,41 +158,50 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned
#undef CHECK_IOCTL #undef CHECK_IOCTL
close(frontend); close(frontend);
printf("ioclt_FrontEndControl: exit\n");
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* ioctl_InfoFrontend : return information about given frontend * ioctl_InfoFrontend : return information about given frontend
*****************************************************************************/ *****************************************************************************/
int ioctl_InfoFrontend(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,
unsigned int u_adapter, unsigned int u_device)
{ {
int front; int front;
int ret;
char frontend[] = FRONTEND; char frontend[] = FRONTEND;
int i_len; int i_len;
printf("ioclt_InfoFrontEnd: enter\n");
i_len = sizeof(FRONTEND); i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len) if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{ {
printf( "error: snprintf() truncated string for FRONTEND" ); msg_Err(p_input, "snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0'; frontend[sizeof(FRONTEND)] = '\0';
} }
printf("ioclt_InfoFrontEnd: Opening device %s\n", frontend); msg_Dbg(p_input, "Opening device %s", frontend);
if((front = open(frontend,O_RDWR)) < 0) if((front = open(frontend,O_RDWR)) < 0)
{ {
return -1; # 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;
} }
/* Determine type of frontend */ /* Determine type of frontend */
if (ioctl(front, FE_GET_INFO, info) < 0) if ((ret=ioctl(front, FE_GET_INFO, info)) < 0)
{ {
close(front); close(front);
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl FE_GET_INFO failed (%d) %s", ret, strerror(errno));
# else
msg_Err(p_input, "ioctl FE_GET_INFO failed (%d)", ret);
# endif
return -1; return -1;
} }
#if 1 msg_Dbg(p_input, "Frontend Info:\tname = %s\n\t\tfrequency_min = %d\n\t\tfrequency_max = %d\n\t\tfrequency_stepsize = %d\n\t\tfrequency_tolerance = %d\n\t\tsymbol_rate_min = %d\n\t\tsymbol_rate_max = %d\n\t\tsymbol_rate_tolerance (ppm) = %d\n\t\tnotifier_delay (ms)= %d\n",
printf( "Frontend Info:\tname = %s\n\t\tfrequency_min = %d\n\t\tfrequency_max = %d\n\t\tfrequency_stepsize = %d\n\t\tfrequency_tolerance = %d\n\t\tsymbol_rate_min = %d\n\t\tsymbol_rate_max = %d\n\t\tsymbol_rate_tolerance (ppm) = %d\n\t\tnotifier_delay (ms)= %d\n",
info->name, info->name,
info->frequency_min, info->frequency_min,
info->frequency_max, info->frequency_max,
...@@ -158,101 +211,110 @@ int ioctl_InfoFrontend(struct dvb_frontend_info *info, unsigned int u_adapter, u ...@@ -158,101 +211,110 @@ int ioctl_InfoFrontend(struct dvb_frontend_info *info, unsigned int u_adapter, u
info->symbol_rate_max, info->symbol_rate_max,
info->symbol_rate_tolerance, info->symbol_rate_tolerance,
info->notifier_delay ); info->notifier_delay );
#endif
close(front); close(front);
printf("ioclt_InfoFrontEnd: exit\n");
return 0; return 0;
} }
// CPR ---> =================================================================== int ioctl_DiseqcSendMsg (input_thread_t *p_input, int fd, fe_sec_voltage_t v, struct diseqc_cmd_t **cmd,
struct diseqc_cmd {
struct dvb_diseqc_master_cmd cmd;
uint32_t wait;
};
struct diseqc_cmd 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 }
};
int diseqc_send_msg (int fd, fe_sec_voltage_t v, struct diseqc_cmd **cmd,
fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b) fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b)
{ {
int err; int err;
printf("diseqc_send_msg: enter\n"); if ((err = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF))<0)
if ((err = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF))) {
return err; # 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));
if ((err = ioctl(fd, FE_SET_VOLTAGE, v))) # else
return err; msg_Err(p_input, "ioclt FE_SET_TONE failed, tone=%s (%d)", SEC_TONE_ON ? "on" : "off", err);
# endif
msleep(15); return err;
while (*cmd) { }
printf("msg: %02x %02x %02x %02x %02x %02x\n", if ((err = ioctl(fd, FE_SET_VOLTAGE, v))<0)
(*cmd)->cmd.msg[0], (*cmd)->cmd.msg[1], {
(*cmd)->cmd.msg[2], (*cmd)->cmd.msg[3], # ifdef HAVE_ERRNO_H
(*cmd)->cmd.msg[4], (*cmd)->cmd.msg[5]); msg_Err(p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d) %s", v, err, strerror(errno));
# else
msg_Err(p_input, "ioclt FE_SET_VOLTAGE failed, voltage=%d (%d)", v, err);
# endif
return err;
}
if ((err = ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &(*cmd)->cmd))) msleep(15);
return err; while (*cmd)
{
msg_Dbg(p_input, "msg: %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 ((err = ioctl(fd, 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));
# else
msg_Err(p_input, "ioclt FE_DISEQC_SEND_MASTER_CMD failed (%d)", err);
# endif
return err;
}
msleep((*cmd)->wait); msleep((*cmd)->wait);
cmd++; cmd++;
} }
msleep(15); msleep(15);
if ((err = ioctl(fd, FE_DISEQC_SEND_BURST, b))) if ((err = ioctl(fd, FE_DISEQC_SEND_BURST, b))<0)
return err; {
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d) %s",b, err, strerror(errno));
# else
msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d)",b, err);
# endif
return err;
}
msleep(15);
msleep(15); if ((err = ioctl(fd, FE_SET_TONE, t))<0)
{
printf("diseqc_send_msg: exit\n"); # ifdef HAVE_ERRNO_H
return ioctl(fd, FE_SET_TONE, t); msg_Err(p_input, "ioctl FE_SET_TONE failed, tone=%d (%d) %s", t, err, strerror(errno));
# else
msg_Err(p_input, "ioctl FE_SET_TONE failed, tone=%d (%d)", t, err);
# endif
return err;
}
return err;
} }
int setup_switch (int frontend_fd, int switch_pos, int voltage_18, int hiband) int ioctl_SetupSwitch (input_thread_t *p_input, int frontend_fd, int switch_pos, int voltage_18, int hiband)
{ {
struct diseqc_cmd *cmd[2] = { NULL, NULL }; int ret;
int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0); struct diseqc_cmd_t *cmd[2] = { NULL, NULL };
int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
printf("setup_switch: enter\n");
printf("switch pos %i, %sV, %sband\n", msg_Dbg(p_input, "ioctl_SetupSwitch: switch pos %i, %sV, %sband",
switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo"); switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo");
msg_Dbg(p_input, "ioctl_SetupSwitch: index %i", i);
printf("index %i\n", 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))) return -EINVAL;
return -EINVAL;
cmd[0] = &switch_cmds[i];
cmd[0] = &switch_cmds[i];
if ((ret = ioctl_DiseqcSendMsg (p_input, frontend_fd,
printf("setup_switch: exit\n"); (i % 2) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13,
return diseqc_send_msg (frontend_fd, cmd,
i % 2 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13, (i/2) % 2 ? SEC_TONE_ON : SEC_TONE_OFF,
cmd, (i/4) % 2 ? SEC_MINI_B : SEC_MINI_A))<0)
(i/2) % 2 ? SEC_TONE_ON : SEC_TONE_OFF, {
(i/4) % 2 ? SEC_MINI_B : SEC_MINI_A); msg_Err(p_input, "ioctl_DiseqcSendMsg() failed (%d)", ret);
return ret;
}
return ret;
} }
// <--- CPR ===================================================================
#define SWITCHFREQ 11700000 #define SWITCHFREQ 11700000
#define LOF_HI 10600000 #define LOF_HI 10600000
#define LOF_LO 9750000 #define LOF_LO 9750000
...@@ -260,34 +322,43 @@ int setup_switch (int frontend_fd, int switch_pos, int voltage_18, int hiband) ...@@ -260,34 +322,43 @@ int setup_switch (int frontend_fd, int switch_pos, int voltage_18, int hiband)
/***************************************************************************** /*****************************************************************************
* ioctl_SetQPSKFrontend : controls the FE device * ioctl_SetQPSKFrontend : controls the FE device
*****************************************************************************/ *****************************************************************************/
int ioctl_SetQPSKFrontend ( struct dvb_frontend_parameters fep, int b_polarisation, unsigned int u_adapter, unsigned int u_device ) int ioctl_SetQPSKFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep,
int b_polarisation, unsigned int u_adapter, unsigned int u_device )
{ {
int front; int front;
int rc; int ret;
int i; int i;
int hiband; int hiband;
char frontend[] = FRONTEND; char frontend[] = FRONTEND;
int i_len; int i_len;
printf("ioctl_SetQPSKFrontend: enter\n");
i_len = sizeof(FRONTEND); i_len = sizeof(FRONTEND);
if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len) if (snprintf(frontend, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{ {
printf( "error: snprintf() truncated string for FRONTEND" ); msg_Err(p_input, "error: snprintf() truncated string for FRONTEND" );
frontend[sizeof(FRONTEND)] = '\0'; frontend[sizeof(FRONTEND)] = '\0';
} }
printf("ioctl_SetQPSKFrontend: Opening frontend %s\n", frontend);
/* Open the frontend device */ /* Open the frontend device */
msg_Dbg(p_input, "Opening frontend %s", frontend);
if((front = open(frontend,O_RDWR)) < 0) if((front = open(frontend,O_RDWR)) < 0)
{ {
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "failed to open frontend (%s)", strerror(errno));
# else
msg_Err(p_input, "failed to open frontend");
# endif
return -1; return -1;
} }
/* Set the frequency of the transponder, taking into account the /* Set the frequency of the transponder, taking into account the
local frequencies of the LNB */ local frequencies of the LNB */
hiband = (fep.frequency >= SWITCHFREQ); hiband = (fep.frequency >= SWITCHFREQ);
setup_switch (front, 0, b_polarisation, hiband ); if ((ret=ioctl_SetupSwitch (p_input, front, 0, b_polarisation, hiband))<0)
{
msg_Err(p_input, "ioctl_SetupSwitch failed (%d)", ret);
return -1;
}
if (hiband) if (hiband)
fep.frequency -= LOF_HI; fep.frequency -= LOF_HI;
...@@ -295,107 +366,127 @@ int ioctl_SetQPSKFrontend ( struct dvb_frontend_parameters fep, int b_polarisati ...@@ -295,107 +366,127 @@ int ioctl_SetQPSKFrontend ( struct dvb_frontend_parameters fep, int b_polarisati
fep.frequency -= LOF_LO; fep.frequency -= LOF_LO;
/* Now send it all to the frontend device */ /* Now send it all to the frontend device */
if (ioctl(front, FE_SET_FRONTEND, &fep) < 0) if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
{ {
printf("ioctl_SetQPSKFrontend: ioctl FE_SET_FRONTEND failed\n");
close(front); close(front);
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_SetQPSKFrontend: ioctl FE_SET_FRONTEND failed (%d) %s", ret, strerror(errno));
# else
msg_Err(p_input, "ioctl_SetQPSKFrontend: ioctl FE_SET_FRONTEND failed (%d)", ret);
# endif
return -1; return -1;
} }
for (i=0; i<3; i++) for (i=0; i<3; i++)
{ {
fe_status_t s; fe_status_t s;
ioctl(front, FE_READ_STATUS, &s); if ((ret=ioctl(front, FE_READ_STATUS, &s))<0)
printf("ioctl_SetQPSKFrontend: tuning status == 0x%02x!!! ...", s); {
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl FE_READ_STATUS failed (%d) %s", ret, strerror(errno));
# else
msg_Err(p_input, "ioctl FE_READ_STATUS failed (%d)", ret);
# endif
}
if (s & FE_HAS_LOCK) if (s & FE_HAS_LOCK)
{ {
printf( "tuning succeeded\n" ); msg_Dbg(p_input, "ioctl_SetQPSKFrontend: tuning status == 0x%02x!!! ..."
rc = 0; "tuning succeeded", s);
ret = 0;
} }
else else
{ {
printf( "tuning failed\n"); msg_Dbg(p_input, "ioctl_SetQPSKFrontend: tuning status == 0x%02x!!! ..."
rc = -1; "tuning failed", s);
ret = -1;
} }
usleep( 500000 ); usleep( 500000 );
} }
/* Close front end device */ /* Close front end device */
close(front); close(front);
printf("ioctl_SetQPSKFrontend: exit\n"); return ret;
return rc;
} }
/****************************************************************** /******************************************************************
* Check completion of the frontend control sequence * Check completion of the frontend control sequence
******************************************************************/ ******************************************************************/
static int ioctl_CheckQPSK(int front) static int ioctl_CheckQPSK(input_thread_t * p_input, int front)
{ {
int ret;
struct pollfd pfd[1]; struct pollfd pfd[1];
struct dvb_frontend_event event; struct dvb_frontend_event event;
/* poll for QPSK event to check if tuning worked */ /* poll for QPSK event to check if tuning worked */
pfd[0].fd = front; pfd[0].fd = front;
pfd[0].events = POLLIN; pfd[0].events = POLLIN;
printf("ioctl_CheckQPSK: enter\n");
if (poll(pfd,1,3000)) if (poll(pfd,1,3000))
{ {
if (pfd[0].revents & POLLIN) if (pfd[0].revents & POLLIN)
{ {
if ( ioctl(front, FE_GET_EVENT, &event) < 0) if ( (ret=ioctl(front, FE_GET_EVENT, &event)) < 0)
{ {
printf("ioctl_CheckQPSK: ioctl FE_GET_EVENT failed\n"); # ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_CheckQPSK: ioctl FE_GET_EVENT failed (%d) %s", ret, strerror(errno));
# else
msg_Err(p_input, "ioctl_CheckQPSK: ioctl FE_GET_EVENT failed (%d)", ret);
# endif
return -5; return -5;
} }
switch(event.status) switch(event.status)
{ {
case FE_HAS_SIGNAL: /* found something above the noise level */ case FE_HAS_SIGNAL: /* found something above the noise level */
printf("ioctl_CheckQPSK: FE_HAS_SIGNAL\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_SIGNAL");
break; break;
case FE_HAS_CARRIER: /* found a DVB signal */ case FE_HAS_CARRIER: /* found a DVB signal */
printf("ioctl_CheckQPSK: FE_HAS_CARRIER\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_CARRIER");
break; break;
case FE_HAS_VITERBI: /* FEC is stable */ case FE_HAS_VITERBI: /* FEC is stable */
printf("ioctl_CheckQPSK: FE_HAS_VITERBI\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_VITERBI");
break; break;
case FE_HAS_SYNC: /* found sync bytes */ case FE_HAS_SYNC: /* found sync bytes */
printf("ioctl_CheckQPSK: FE_HAS_SYNC\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_SYNC");
break; break;
case FE_HAS_LOCK: /* everything's working... */ case FE_HAS_LOCK: /* everything's working... */
printf("ioctl_CheckQPSK: FE_HAS_LOCK\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_LOCK");
break; break;
case FE_TIMEDOUT: /* no lock within the last ~2 seconds */ case FE_TIMEDOUT: /* no lock within the last ~2 seconds */
printf("ioctl_CheckQPSK: FE_TIMEDOUT\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_TIMEDOUT");
return -2; return -2;
case FE_REINIT: /* frontend was reinitialized, */ case FE_REINIT: /* frontend was reinitialized, */
/* application is recommned to reset */ /* application is recommned to reset */
/* DiSEqC, tone and parameters */ /* DiSEqC, tone and parameters */
printf("ioctl_CheckQPSK: FE_REINIT\n"); msg_Dbg(p_input, "ioctl_CheckQPSK: FE_REINIT");
return -1; return -1;
} }
} }
else else
{ {
/* should come here */ /* should come here */
printf("ioctl_CheckQPSK: event() failed\n"); msg_Err(p_input, "ioctl_CheckQPSK: event() failed");
return -3; return -3;
} }
} }
else else
{ {
printf("ioctl_CheckQPSK: poll() failed\n"); # ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_CheckQPSK: poll() failed (%s)", strerror(errno));
# else
msg_Err(p_input, "ioctl_CheckQPSK: poll() failed");
# endif
return -4; return -4;
} }
printf("ioctl_CheckQPSK: exit\n");
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* ioctl_SetDMXFilter : controls the demux to add a filter * ioctl_SetDMXFilter : controls the demux to add a filter
*****************************************************************************/ *****************************************************************************/
int ioctl_SetDMXFilter( 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,
unsigned int u_adapter, unsigned int u_device )
{ {
struct dmx_pes_filter_params s_filter_params; struct dmx_pes_filter_params s_filter_params;
char dmx[] = DMX; char dmx[] = DMX;
...@@ -403,21 +494,24 @@ int ioctl_SetDMXFilter( int i_pid, int * pi_fd , int i_type, unsigned int u_adap ...@@ -403,21 +494,24 @@ int ioctl_SetDMXFilter( int i_pid, int * pi_fd , int i_type, unsigned int u_adap
int result; int result;
/* We first open the device */ /* We first open the device */
printf("ioctl_SetDMXFIlter: enter\n");
i_len = sizeof(DMX); i_len = sizeof(DMX);
if (snprintf( dmx, sizeof(DMX), DMX, u_adapter, u_device) >= i_len) if (snprintf( dmx, sizeof(DMX), DMX, u_adapter, u_device) >= i_len)
{ {
printf( "error: snprintf() truncated string for DMX" ); msg_Err(p_input, "snprintf() truncated string for DMX" );
dmx[sizeof(DMX)] = '\0'; dmx[sizeof(DMX)] = '\0';
} }
printf("ioctl_SetDMXFIlter: Opening demux device %s\n", dmx); msg_Dbg(p_input, "Opening demux device %s", dmx);
if ((*pi_fd = open(dmx, O_RDWR|O_NONBLOCK)) < 0) 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));
# else
msg_Err(p_input, "ioctl_SetDMXFIlter: opening device failed");
# endif
return -1; return -1;
} }
printf( "@@@ Trying to set PMT id to=%d for type %d\n", i_pid, i_type );
/* We fill the DEMUX structure : */ /* We fill the DEMUX structure : */
s_filter_params.pid = i_pid; s_filter_params.pid = i_pid;
s_filter_params.input = DMX_IN_FRONTEND; s_filter_params.input = DMX_IN_FRONTEND;
...@@ -425,38 +519,52 @@ int ioctl_SetDMXFilter( int i_pid, int * pi_fd , int i_type, unsigned int u_adap ...@@ -425,38 +519,52 @@ int ioctl_SetDMXFilter( int i_pid, int * pi_fd , int i_type, unsigned int u_adap
switch ( i_type ) switch ( i_type )
{ {
case 1: case 1:
printf("ioctl_SetDMXFIlter: DMX_PES_VIDEO\n"); msg_Dbg(p_input, "ioctl_SetDMXFIlter: DMX_PES_VIDEO for PMT %d", i_pid);
s_filter_params.pes_type = DMX_PES_VIDEO; s_filter_params.pes_type = DMX_PES_VIDEO;
break; break;
case 2: case 2:
printf("ioctl_SetDMXFIlter: DMX_PES_AUDIO\n"); msg_Dbg(p_input, "ioctl_SetDMXFIlter: DMX_PES_AUDIO for PMT %d", i_pid);
s_filter_params.pes_type = DMX_PES_AUDIO; s_filter_params.pes_type = DMX_PES_AUDIO;
break; break;
case 3: case 3:
printf("ioctl_SetDMXFIlter: DMX_PES_OTHER\n"); msg_Dbg(p_input, "ioctl_SetDMXFIlter: DMX_PES_OTHER for PMT %d", i_pid);
s_filter_params.pes_type = DMX_PES_OTHER; s_filter_params.pes_type = DMX_PES_OTHER;
break; break;
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; s_filter_params.flags = DMX_IMMEDIATE_START;
/* We then give the order to the device : */ /* 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)
{ {
printf("ioctl_SetDMXFIlter: ioctl failed with %d (%s)\n",result, strerror(errno)); # ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl_SetDMXFIlter: ioctl failed with %d (%s)",result, strerror(errno));
# else
msg_Err(p_input, "ioctl_SetDMXFIlter: ioctl failed with %d",result);
# endif
return -1; return -1;
} }
printf("ioctl_SetDMXFIlter: exit\n");
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* ioctl_UnsetDMXFilter : removes a filter * ioctl_UnsetDMXFilter : removes a filter
*****************************************************************************/ *****************************************************************************/
int ioctl_UnsetDMXFilter(int demux) int ioctl_UnsetDMXFilter(input_thread_t * p_input, int demux)
{ {
printf("ioctl_UnsetDMXFIlter: enter\n"); int ret;
ioctl(demux, DMX_STOP);
if ((ret=ioctl(demux, DMX_STOP))<0)
{
# ifdef HAVE_ERRNO_H
msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d) %s", demux, ret, strerror(errno));
# else
msg_Err(p_input, "ioctl DMX_STOP failed for demux %d (%d)", demux, ret);
# endif
return -1;
}
close(demux); close(demux);
printf("ioctl_UnsetDMXFIlter: exit\n");
return 0; return 0;
} }
...@@ -26,11 +26,6 @@ ...@@ -26,11 +26,6 @@
/***************************************************************************** /*****************************************************************************
* Devices location * Devices location
*****************************************************************************/ *****************************************************************************/
/*
#define DMX "/dev/dvb/adapter1/demux0"
#define FRONTEND "/dev/dvb/adapter1/frontend0"
#define DVR "/dev/dvb/adapter1/dvr0"
*/
#define DMX "/dev/dvb/adapter%d/demux%d" #define DMX "/dev/dvb/adapter%d/demux%d"
#define FRONTEND "/dev/dvb/adapter%d/frontend%d" #define FRONTEND "/dev/dvb/adapter%d/frontend%d"
#define DVR "/dev/dvb/adapter%d/dvr%d" #define DVR "/dev/dvb/adapter%d/dvr%d"
...@@ -38,8 +33,9 @@ ...@@ -38,8 +33,9 @@
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned int u_adapter, unsigned int u_device ); int ioctl_FrontendControl(input_thread_t *p_input, int freq, int pol, int lnb_slof, int diseqc, unsigned int u_adapter, unsigned int u_device );
int ioctl_SetQPSKFrontend ( struct dvb_frontend_parameters fep, int b_polarisation, unsigned int u_adapter, unsigned int u_device ); int ioctl_SetQPSKFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation, unsigned int u_adapter, unsigned int u_device );
int ioctl_SetDMXFilter( 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, unsigned int u_adapter, unsigned int u_device );
int ioctl_UnsetDMXFilter( int ); int ioctl_UnsetDMXFilter(input_thread_t * p_input, int );
int ioctl_InfoFrontend(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, unsigned int u_adapter, unsigned int u_device );
...@@ -70,8 +70,8 @@ void E_(Close) ( vlc_object_t * ); ...@@ -70,8 +70,8 @@ void E_(Close) ( vlc_object_t * );
#define LNB_SLOF_TEXT N_("antenna lnb_slof (kHz)") #define LNB_SLOF_TEXT N_("antenna lnb_slof (kHz)")
#define LNB_SLOF_LONGTEXT "" #define LNB_SLOF_LONGTEXT ""
#define NO_PROBE_TEXT N_("do not probe the dvb card for capabilities") #define PROBE_TEXT N_("probe the dvb card for capabilities (default disabled)")
#define NO_PROBE_LONGTEXT N_("some dvb cards do not like to be probed for their capabilities") #define PROBE_LONGTEXT N_("some dvb cards do not like to be probed for their capabilities")
vlc_module_begin(); vlc_module_begin();
add_category_hint( N_("Input"), NULL, VLC_FALSE ); add_category_hint( N_("Input"), NULL, VLC_FALSE );
...@@ -88,10 +88,9 @@ vlc_module_begin(); ...@@ -88,10 +88,9 @@ vlc_module_begin();
LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT, VLC_FALSE ); LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT, VLC_FALSE );
add_integer( "lnb-slof", 11700, NULL, add_integer( "lnb-slof", 11700, NULL,
LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT, VLC_FALSE ); LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT, VLC_FALSE );
add_bool( "no-probe", 1, NULL, NO_PROBE_TEXT, NO_PROBE_LONGTEXT, VLC_FALSE ); add_bool( "probe", 0, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_FALSE );
set_description( _("DVB input module with v4l2 support") ); set_description( _("DVB input module with v4l2 support") );
set_capability( "access", 0 ); set_capability( "access", 0 );
// add_shortcut( "satellite" );
add_shortcut( "qpsk" ); add_shortcut( "qpsk" );
// add_shortcut( "cable" ); // add_shortcut( "cable" );
// add_shortcut( "terrestrial" ); // add_shortcut( "terrestrial" );
......
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