*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* 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
* it under the terms of the GNU General Public License as published by
#include <fcntl.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
# include <strings.h>
int i_fec = 0;
fe_code_rate_t fe_fec = FEC_NONE;
vlc_bool_t b_diseqc;
- vlc_bool_t b_no_probe;
+ vlc_bool_t b_probe;
int i_lnb_lof1;
int i_lnb_lof2;
int i_lnb_slof;
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
u_adapter = config_GetInt( p_input, "adapter" );
u_device = config_GetInt( p_input, "device" );
/* Determine frontend device information and capabilities */
- b_no_probe = config_GetInt( p_input, "no-probe" );
- if (!b_no_probe)
+ b_probe = config_GetInt( p_input, "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" );
return -1;
{
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);
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_info.name = frontend;
+ strncpy(frontend_info.name, frontend, 128);
frontend_info.type = FE_QPSK;
frontend_info.frequency_max = 12999;
frontend_info.frequency_min = 10000;
/* 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 )
{
psz_parser = psz_next + 1;
if( *psz_next )
{
psz_parser = psz_next + 1;
- u_srate = (int)strtol( psz_parser, &psz_next, 10 );
+ u_srate = (unsigned int)strtol( psz_parser, &psz_next, 10 );
}
}
}
}
}
- if( b_polarisation && b_polarisation != 1 )
+ if( b_polarisation && (b_polarisation != 1) )
{
msg_Warn( p_input, "invalid polarization, using default one" );
b_polarisation = config_GetInt( p_input, "polarization" );
}
}
- if( (i_fec > 7) || (i_fec < 1) )
+ if( (i_fec > 9) || (i_fec < 1) )
{
msg_Warn( p_input, "invalid FEC, using default one" );
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" );
return -1;
default:
/* cannot happen */
fe_fec = FEC_NONE;
+ msg_Err( p_input, "invalid FEC (unknown)" );
break;
}
i_len = sizeof(DVR);
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';
}
msg_Dbg( p_input, "opening DVR device '%s'", dvr );
if( (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) );
+# else
+ msg_Warn( p_input, "cannot open `%s'", dvr );
+# endif
free( p_satellite );
return -1;
}
i_lnb_slof = config_GetInt( p_input, "lnb-slof" );
/* Initialize the Satellite Card */
- msg_Dbg( p_input, "initializing Sat Card with Freq: %d, Pol: %d, "
- "FEC: %d, Srate: %d", u_freq, b_polarisation, fe_fec, u_srate );
+ msg_Dbg( p_input, "initializing Sat Card with Freq: %u, Pol: %d, "
+ "FEC: %d, Srate: %u", u_freq, b_polarisation, fe_fec, u_srate );
- msg_Dbg( p_input, "initializing frontend 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 ))
+ switch (ioctl_SetQPSKFrontend (p_input, fep, b_polarisation, u_adapter, u_device ))
{
case -2:
msg_Err( p_input, "frontend returned an unexpected event" );
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" );
+# endif
close( p_satellite->i_handle );
free( p_satellite );
return -1;
}
- msg_Dbg( p_input, "@@@ Initialising input stream\n" );
-
if( input_InitStream( p_input, sizeof( stream_ts_data_t ) ) == -1 )
{
msg_Err( p_input, "could not initialize stream structure" );
p_input->i_mtu = SATELLITE_READ_ONCE * TS_PACKET_SIZE;
p_input->stream.i_method = INPUT_METHOD_SATELLITE;
- msg_Dbg( p_input, "@@@ Leaving E_(Open)\n" );
return 0;
}
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
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
}
ssize_t i_ret;
unsigned int u_adapter = 1;
unsigned int u_device = 0;
-
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
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++ )
{
- 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 )
{
- msg_Dbg( p_input, "setting filter on pmt pid %d",
- p_input->stream.pp_programs[i]->pp_es[0]->i_id );
-
- ioctl_SetDMXFilter( 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,
3, u_adapter, u_device );
}
# endif
}
- msg_Dbg( p_input, "@@@ Searched all, returning %d\n", i_ret );
-
return i_ret;
}
unsigned int u_adapter = 1;
unsigned int u_device = 0;
- msg_Dbg( p_input, "@@@ SatelliteSetProgram enter\n" );
-
// 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_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;
}
#undef p_es
case MPEG2_VIDEO_ES:
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;
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
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 );
}
break;
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 );
break;
#undef p_es
p_input->stream.p_selected_program = p_new_prg;
- msg_Dbg( p_input, "@@@ SatelliteSetProgram exit\n" );
return 0;
}
*****************************************************************************/
#include <vlc/vlc.h>
+#include <vlc/input.h>
#include <sys/ioctl.h>
#include <stdio.h>
-#include <string.h>
-#include <errno.h>
+#ifdef HAVE_ERRNO_H
+# include <string.h>
+# include <errno.h>
+#endif
+
#ifdef HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */
#endif
#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
*****************************************************************************/
-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;
fe_sec_tone_mode_t tone;
char front[] = FRONTEND;
int i_len;
- printf("ioclt_FrontEndControl: enter\n");
i_len = sizeof(FRONTEND);
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';
}
- printf("ioclt_FrontEndControl: Opening frontend %s\n",front);
+ msg_Dbg(p_input, "Opening frontend %s",front);
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;
}
cmd.msg_len = 4;
/* 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); \
- 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_VOLTAGE, voltage));
msleep(15);
/* 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));
msleep(15);
CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_BURST, &cmd));
#undef CHECK_IOCTL
close(frontend);
- printf("ioclt_FrontEndControl: exit\n");
return 0;
}
/*****************************************************************************
* 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 ret;
char frontend[] = FRONTEND;
int i_len;
- printf("ioclt_InfoFrontEnd: enter\n");
i_len = sizeof(FRONTEND);
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';
}
- printf("ioclt_InfoFrontEnd: Opening device %s\n", frontend);
+ msg_Dbg(p_input, "Opening device %s", frontend);
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 */
- if (ioctl(front, FE_GET_INFO, info) < 0)
+ if ((ret=ioctl(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));
+# else
+ msg_Err(p_input, "ioctl FE_GET_INFO failed (%d)", ret);
+# endif
return -1;
}
-#if 1
- 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",
+ 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",
info->name,
info->frequency_min,
info->frequency_max,
info->symbol_rate_max,
info->symbol_rate_tolerance,
info->notifier_delay );
-#endif
+
close(front);
- printf("ioclt_InfoFrontEnd: exit\n");
return 0;
}
-// CPR ---> ===================================================================
-
-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,
+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 err;
-
- printf("diseqc_send_msg: enter\n");
- if ((err = ioctl(fd, FE_SET_TONE, SEC_TONE_OFF)))
- return err;
-
- if ((err = ioctl(fd, FE_SET_VOLTAGE, v)))
- return err;
-
- msleep(15);
- while (*cmd) {
- printf("msg: %02x %02x %02x %02x %02x %02x\n",
- (*cmd)->cmd.msg[0], (*cmd)->cmd.msg[1],
- (*cmd)->cmd.msg[2], (*cmd)->cmd.msg[3],
- (*cmd)->cmd.msg[4], (*cmd)->cmd.msg[5]);
+ int err;
+
+ if ((err = ioctl(fd, 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));
+# else
+ msg_Err(p_input, "ioclt FE_SET_TONE failed, tone=%s (%d)", SEC_TONE_ON ? "on" : "off", err);
+# endif
+ return err;
+ }
+ if ((err = ioctl(fd, 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));
+# 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)))
- return err;
+ msleep(15);
+ 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);
- cmd++;
- }
+ msleep((*cmd)->wait);
+ cmd++;
+ }
- msleep(15);
+ msleep(15);
- if ((err = ioctl(fd, FE_DISEQC_SEND_BURST, b)))
- return err;
+ if ((err = ioctl(fd, 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));
+# else
+ msg_Err(p_input, "ioctl FE_DISEQC_SEND_BURST failed, burst=%d (%d)",b, err);
+# endif
+ return err;
+ }
+ msleep(15);
- msleep(15);
-
- printf("diseqc_send_msg: exit\n");
- return ioctl(fd, FE_SET_TONE, t);
+ if ((err = ioctl(fd, 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));
+# 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 i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
-
- printf("setup_switch: enter\n");
- printf("switch pos %i, %sV, %sband\n",
- switch_pos, voltage_18 ? "18" : "13", hiband ? "hi" : "lo");
-
- printf("index %i\n", i);
-
- if (i < 0 || i >= (int)(sizeof(switch_cmds)/sizeof(struct diseqc_cmd)))
- return -EINVAL;
-
- cmd[0] = &switch_cmds[i];
-
- printf("setup_switch: exit\n");
- return diseqc_send_msg (frontend_fd,
- 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);
+ int ret;
+ struct diseqc_cmd_t *cmd[2] = { NULL, NULL };
+ int i = 4 * switch_pos + 2 * hiband + (voltage_18 ? 1 : 0);
+
+ 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);
+
+ 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,
+ (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)
+ {
+ msg_Err(p_input, "ioctl_DiseqcSendMsg() failed (%d)", ret);
+ return ret;
+ }
+
+ return ret;
}
-// <--- CPR ===================================================================
#define SWITCHFREQ 11700000
#define LOF_HI 10600000
#define LOF_LO 9750000
/*****************************************************************************
* 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 rc;
+ int ret;
int i;
int hiband;
char frontend[] = FRONTEND;
int i_len;
- printf("ioctl_SetQPSKFrontend: enter\n");
i_len = sizeof(FRONTEND);
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';
}
- printf("ioctl_SetQPSKFrontend: Opening frontend %s\n", frontend);
/* Open the frontend device */
+ msg_Dbg(p_input, "Opening frontend %s", frontend);
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;
}
/* Set the frequency of the transponder, taking into account the
local frequencies of the LNB */
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)
fep.frequency -= LOF_HI;
fep.frequency -= LOF_LO;
/* 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);
+# 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;
}
for (i=0; i<3; i++)
{
fe_status_t s;
- ioctl(front, FE_READ_STATUS, &s);
- printf("ioctl_SetQPSKFrontend: tuning status == 0x%02x!!! ...", s);
+ if ((ret=ioctl(front, FE_READ_STATUS, &s))<0)
+ {
+# 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)
{
- printf( "tuning succeeded\n" );
- rc = 0;
+ msg_Dbg(p_input, "ioctl_SetQPSKFrontend: tuning status == 0x%02x!!! ..."
+ "tuning succeeded", s);
+ ret = 0;
}
else
{
- printf( "tuning failed\n");
- rc = -1;
+ msg_Dbg(p_input, "ioctl_SetQPSKFrontend: tuning status == 0x%02x!!! ..."
+ "tuning failed", s);
+ ret = -1;
}
usleep( 500000 );
}
/* Close front end device */
close(front);
- printf("ioctl_SetQPSKFrontend: exit\n");
- return rc;
+ return ret;
}
/******************************************************************
* 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 dvb_frontend_event event;
/* poll for QPSK event to check if tuning worked */
pfd[0].fd = front;
pfd[0].events = POLLIN;
- printf("ioctl_CheckQPSK: enter\n");
if (poll(pfd,1,3000))
{
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;
}
switch(event.status)
{
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;
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;
case FE_HAS_VITERBI: /* FEC is stable */
- printf("ioctl_CheckQPSK: FE_HAS_VITERBI\n");
+ msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_VITERBI");
break;
case FE_HAS_SYNC: /* found sync bytes */
- printf("ioctl_CheckQPSK: FE_HAS_SYNC\n");
+ msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_SYNC");
break;
case FE_HAS_LOCK: /* everything's working... */
- printf("ioctl_CheckQPSK: FE_HAS_LOCK\n");
+ msg_Dbg(p_input, "ioctl_CheckQPSK: FE_HAS_LOCK");
break;
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;
case FE_REINIT: /* frontend was reinitialized, */
/* application is recommned to reset */
/* DiSEqC, tone and parameters */
- printf("ioctl_CheckQPSK: FE_REINIT\n");
+ msg_Dbg(p_input, "ioctl_CheckQPSK: FE_REINIT");
return -1;
}
}
else
{
/* should come here */
- printf("ioctl_CheckQPSK: event() failed\n");
+ msg_Err(p_input, "ioctl_CheckQPSK: event() failed");
return -3;
}
}
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;
}
- printf("ioctl_CheckQPSK: exit\n");
return 0;
}
/*****************************************************************************
* 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;
char dmx[] = DMX;
int result;
/* We first open the device */
- printf("ioctl_SetDMXFIlter: enter\n");
i_len = sizeof(DMX);
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';
}
- 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)
{
+# 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;
}
- printf( "@@@ Trying to set PMT id to=%d for type %d\n", i_pid, i_type );
/* We fill the DEMUX structure : */
s_filter_params.pid = i_pid;
s_filter_params.input = DMX_IN_FRONTEND;
switch ( i_type )
{
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;
break;
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;
break;
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;
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;
/* 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;
}
- printf("ioctl_SetDMXFIlter: exit\n");
return 0;
}
/*****************************************************************************
* 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");
- ioctl(demux, DMX_STOP);
+ int ret;
+
+ 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);
- printf("ioctl_UnsetDMXFIlter: exit\n");
return 0;
}