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

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

parent f853698b
......@@ -5,7 +5,6 @@
*
* 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
......@@ -40,8 +39,11 @@
#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>
......@@ -84,7 +86,7 @@ int E_(Open) ( vlc_object_t *p_this )
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;
......@@ -100,20 +102,15 @@ int E_(Open) ( vlc_object_t *p_this )
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;
......@@ -128,14 +125,14 @@ int E_(Open) ( vlc_object_t *p_this )
{
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;
......@@ -144,7 +141,13 @@ int E_(Open) ( vlc_object_t *p_this )
/* 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;
......@@ -156,7 +159,7 @@ int E_(Open) ( vlc_object_t *p_this )
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 );
}
}
}
......@@ -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" );
b_polarisation = config_GetInt( p_input, "polarization" );
......@@ -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" );
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;
......@@ -241,6 +244,7 @@ int E_(Open) ( vlc_object_t *p_this )
default:
/* cannot happen */
fe_fec = FEC_NONE;
msg_Err( p_input, "invalid FEC (unknown)" );
break;
}
......@@ -279,7 +283,7 @@ int E_(Open) ( vlc_object_t *p_this )
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 );
......@@ -287,7 +291,11 @@ int E_(Open) ( vlc_object_t *p_this )
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;
}
......@@ -299,13 +307,10 @@ int E_(Open) ( vlc_object_t *p_this )
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" );
......@@ -336,18 +341,20 @@ int E_(Open) ( vlc_object_t *p_this )
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" );
......@@ -367,7 +374,6 @@ int E_(Open) ( vlc_object_t *p_this )
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;
}
......@@ -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]
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
}
......@@ -409,11 +415,8 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
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" );
......@@ -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 */
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 );
}
......@@ -446,8 +443,6 @@ static ssize_t SatelliteRead( input_thread_t * p_input, byte_t * p_buffer,
# endif
}
msg_Dbg( p_input, "@@@ Searched all, returning %d\n", i_ret );
return i_ret;
}
......@@ -471,8 +466,6 @@ int SatelliteSetProgram( input_thread_t * p_input,
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" );
......@@ -490,7 +483,7 @@ int SatelliteSetProgram( input_thread_t * p_input,
}
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
......@@ -506,19 +499,19 @@ int SatelliteSetProgram( input_thread_t * p_input,
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
......@@ -527,7 +520,6 @@ int SatelliteSetProgram( input_thread_t * p_input,
p_input->stream.p_selected_program = p_new_prg;
msg_Dbg( p_input, "@@@ SatelliteSetProgram exit\n" );
return 0;
}
......
......@@ -24,11 +24,15 @@
*****************************************************************************/
#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
......@@ -49,12 +53,39 @@
#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;
......@@ -63,17 +94,21 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned
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;
}
......@@ -94,18 +129,27 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned
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));
......@@ -114,41 +158,50 @@ int ioctl_FrontendControl( int freq, int pol, int lnb_slof, int diseqc, unsigned
#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,
......@@ -158,101 +211,110 @@ int ioctl_InfoFrontend(struct dvb_frontend_info *info, unsigned int u_adapter, u
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");