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

* Audio is verified to work, it was a problem with the test setup and not with the code ;-).

* Added code to support LNB_LOF1, LNB_LOF2, LNB_SLOF commandline options.
* Cleanup of code.
parent 2cae3dc3
...@@ -82,9 +82,9 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -82,9 +82,9 @@ int E_(Open) ( vlc_object_t *p_this )
unsigned int u_device = 0; unsigned int u_device = 0;
unsigned int u_freq = 0; unsigned int u_freq = 0;
unsigned int u_srate = 0; unsigned int u_srate = 0;
int i_lnb_lof1; unsigned int u_lnb_lof1;
int i_lnb_lof2; unsigned int u_lnb_lof2;
int i_lnb_slof; unsigned int u_lnb_slof;
int i_bandwidth = 0; int i_bandwidth = 0;
int i_modulation = 0; int i_modulation = 0;
int i_guard = 0; int i_guard = 0;
...@@ -143,8 +143,8 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -143,8 +143,8 @@ int E_(Open) ( vlc_object_t *p_this )
else if (strncmp( p_input->psz_access, "terrestrial",11) ==0) else if (strncmp( p_input->psz_access, "terrestrial",11) ==0)
frontend_info.type = FE_OFDM; frontend_info.type = FE_OFDM;
frontend_info.frequency_max = 12999; frontend_info.frequency_max = 12999 * 1000;
frontend_info.frequency_min = 10000; frontend_info.frequency_min = 9750 * 1000;
frontend_info.symbol_rate_max = 30000; frontend_info.symbol_rate_max = 30000;
frontend_info.symbol_rate_min = 1000; frontend_info.symbol_rate_min = 1000;
} }
...@@ -173,6 +173,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -173,6 +173,7 @@ int E_(Open) ( vlc_object_t *p_this )
} }
/* Validating input values */ /* Validating input values */
u_freq *= 1000;
if ( ((u_freq) > frontend_info.frequency_max) || if ( ((u_freq) > frontend_info.frequency_max) ||
((u_freq) < frontend_info.frequency_min) ) ((u_freq) < frontend_info.frequency_min) )
{ {
...@@ -223,16 +224,16 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -223,16 +224,16 @@ int E_(Open) ( vlc_object_t *p_this )
/* Get antenna configuration options */ /* Get antenna configuration options */
b_diseqc = config_GetInt( p_input, "diseqc" ); b_diseqc = config_GetInt( p_input, "diseqc" );
i_lnb_lof1 = config_GetInt( p_input, "lnb-lof1" ); u_lnb_lof1 = config_GetInt( p_input, "lnb-lof1" ) * 1000;
i_lnb_lof2 = config_GetInt( p_input, "lnb-lof2" ); u_lnb_lof2 = config_GetInt( p_input, "lnb-lof2" ) * 1000;
i_lnb_slof = config_GetInt( p_input, "lnb-slof" ); u_lnb_slof = config_GetInt( p_input, "lnb-slof" ) * 1000;
/* Setting frontend parameters for tuning the hardware */ /* Setting frontend parameters for tuning the hardware */
switch( frontend_info.type ) switch( frontend_info.type )
{ {
/* DVB-S: satellite and budget cards (nova) */ /* DVB-S: satellite and budget cards (nova) */
case FE_QPSK: case FE_QPSK:
fep.frequency = u_freq * 1000; fep.frequency = u_freq;
fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation); fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation);
fep.u.qpsk.symbol_rate = u_srate * 1000; fep.u.qpsk.symbol_rate = u_srate * 1000;
fep.u.qpsk.fec_inner = dvb_DecodeFEC(p_input, i_fec); fep.u.qpsk.fec_inner = dvb_DecodeFEC(p_input, i_fec);
...@@ -243,7 +244,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -243,7 +244,7 @@ int E_(Open) ( vlc_object_t *p_this )
case FE_QAM: case FE_QAM:
i_modulation = config_GetInt(p_input, "modulation"); i_modulation = config_GetInt(p_input, "modulation");
fep.frequency = u_freq * 1000; fep.frequency = u_freq;
fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation); fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation);
fep.u.qam.symbol_rate = u_srate * 1000; fep.u.qam.symbol_rate = u_srate * 1000;
fep.u.qam.fec_inner = dvb_DecodeFEC(p_input, i_fec); fep.u.qam.fec_inner = dvb_DecodeFEC(p_input, i_fec);
...@@ -261,7 +262,7 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -261,7 +262,7 @@ int E_(Open) ( vlc_object_t *p_this )
i_guard = config_GetInt(p_input, "guard"); i_guard = config_GetInt(p_input, "guard");
i_hierarchy = config_GetInt(p_input, "hierarchy"); i_hierarchy = config_GetInt(p_input, "hierarchy");
fep.frequency = u_freq * 1000; fep.frequency = u_freq;
fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation); fep.inversion = dvb_DecodeInversion(p_input, (int) b_polarisation);
fep.u.ofdm.bandwidth = dvb_DecodeBandwidth(p_input, i_bandwidth); fep.u.ofdm.bandwidth = dvb_DecodeBandwidth(p_input, i_bandwidth);
fep.u.ofdm.code_rate_HP = dvb_DecodeFEC(p_input, i_code_rate_HP); fep.u.ofdm.code_rate_HP = dvb_DecodeFEC(p_input, i_code_rate_HP);
...@@ -311,7 +312,9 @@ int E_(Open) ( vlc_object_t *p_this ) ...@@ -311,7 +312,9 @@ int E_(Open) ( vlc_object_t *p_this )
} }
/* Initialize the Satellite Card */ /* Initialize the Satellite Card */
switch (ioctl_SetFrontend (p_input, fep, b_polarisation, u_adapter, u_device )) switch (ioctl_SetFrontend (p_input, fep, b_polarisation,
u_lnb_lof1, u_lnb_lof2, u_lnb_slof,
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" );
......
...@@ -81,86 +81,6 @@ struct diseqc_cmd_t switch_cmds[] = ...@@ -81,86 +81,6 @@ struct diseqc_cmd_t switch_cmds[] =
static int ioctl_CheckFrontend(input_thread_t * p_input, int front); static int ioctl_CheckFrontend(input_thread_t * p_input, int front);
/*****************************************************************************
* ioctl_FrontendControl : commands the SEC 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;
fe_sec_voltage_t voltage;
int frontend;
char front[] = FRONTEND;
int i_len;
i_len = sizeof(FRONTEND);
if (snprintf(front, sizeof(FRONTEND), FRONTEND, u_adapter, u_device) >= i_len)
{
msg_Err(p_input, "snprintf() truncated string for FRONTEND" );
front[sizeof(FRONTEND)] = '\0';
}
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;
}
/* Set the frequency of the transponder, taking into account the
local frequencies of the LNB */
tone = (freq<lnb_slof) ? SEC_TONE_OFF : SEC_TONE_ON;
/* Set the polarisation of the transponder by setting the correct
voltage on the universal LNB */
voltage = (pol) ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13;
/* In case we have a DiSEqC, set it to the correct address */
cmd.msg[0] = 0x0; /* framing */
cmd.msg[1] = 0x10; /* address */
cmd.msg[2] = 0x38; /* command */
/* command parameters start at index 3 */
cmd.msg[3] = 0xF0 | ((diseqc * 4) & 0x0F);
cmd.msg_len = 4;
/* Reset everything before sending. */
#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; \
}
#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 */
CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd));
msleep(15);
CHECK_IOCTL(ioctl(frontend, FE_DISEQC_SEND_BURST, &cmd));
msleep(15);
CHECK_IOCTL(ioctl(frontend, FE_SET_TONE, tone));
#undef CHECK_IOCTL
close(frontend);
return 0;
}
/***************************************************************************** /*****************************************************************************
* ioctl_InfoFrontend : return information about given frontend * ioctl_InfoFrontend : return information about given frontend
*****************************************************************************/ *****************************************************************************/
...@@ -367,15 +287,12 @@ int ioctl_SetupSwitch (input_thread_t *p_input, int frontend_fd, int switch_pos, ...@@ -367,15 +287,12 @@ int ioctl_SetupSwitch (input_thread_t *p_input, int frontend_fd, int switch_pos,
return ret; return ret;
} }
#define SWITCHFREQ 11700000
#define LOF_HI 10600000
#define LOF_LO 9750000
/***************************************************************************** /*****************************************************************************
* ioctl_SetFrontend : controls the FE device * ioctl_SetFrontend : controls the FE device
*****************************************************************************/ *****************************************************************************/
int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation,
int b_polarisation, unsigned int u_adapter, unsigned int u_device ) unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
unsigned int u_adapter, unsigned int u_device )
{ {
int front; int front;
int ret; int ret;
...@@ -405,7 +322,8 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters ...@@ -405,7 +322,8 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters
/* 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 >= u_lnb_slof);
if ((ret=ioctl_SetupSwitch (p_input, front, 0, b_polarisation, hiband))<0) if ((ret=ioctl_SetupSwitch (p_input, front, 0, b_polarisation, hiband))<0)
{ {
msg_Err(p_input, "ioctl_SetupSwitch failed (%d)", ret); msg_Err(p_input, "ioctl_SetupSwitch failed (%d)", ret);
...@@ -413,9 +331,9 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters ...@@ -413,9 +331,9 @@ int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters
} }
if (hiband) if (hiband)
fep.frequency -= LOF_HI; fep.frequency -= u_lnb_lof2;
else else
fep.frequency -= LOF_LO; fep.frequency -= u_lnb_lof2;
/* Now send it all to the frontend device */ /* Now send it all to the frontend device */
if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0) if ((ret=ioctl(front, FE_SET_FRONTEND, &fep)) < 0)
......
...@@ -33,8 +33,9 @@ ...@@ -33,8 +33,9 @@
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
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_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation,
int ioctl_SetFrontend (input_thread_t * p_input, struct dvb_frontend_parameters fep, int b_polarisation, unsigned int u_adapter, unsigned int u_device ); unsigned int u_lnb_lof1, unsigned int u_lnb_lof2, unsigned int u_lnb_slof,
unsigned int u_adapter, unsigned int u_device );
int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int *pi_fd, int i_type, unsigned int u_adapter, unsigned int u_device ); int ioctl_SetDMXFilter(input_thread_t * p_input, int i_pid, int *pi_fd, int i_type, unsigned int u_adapter, unsigned int u_device );
int ioctl_UnsetDMXFilter(input_thread_t * p_input, int ); int ioctl_UnsetDMXFilter(input_thread_t * p_input, int );
int ioctl_InfoFrontend(input_thread_t * p_input, struct dvb_frontend_info *info, unsigned int u_adapter, unsigned int u_device ); int ioctl_InfoFrontend(input_thread_t * p_input, struct dvb_frontend_info *info, unsigned int u_adapter, unsigned int u_device );
......
...@@ -106,12 +106,9 @@ vlc_module_begin(); ...@@ -106,12 +106,9 @@ vlc_module_begin();
add_integer( "fec", 3, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_FALSE ); add_integer( "fec", 3, NULL, FEC_TEXT, FEC_LONGTEXT, VLC_FALSE );
add_integer( "symbol-rate", 27500, NULL, SRATE_TEXT, SRATE_LONGTEXT, VLC_FALSE ); add_integer( "symbol-rate", 27500, NULL, SRATE_TEXT, SRATE_LONGTEXT, VLC_FALSE );
add_bool( "diseqc", 0, NULL, DISEQC_TEXT, DISEQC_LONGTEXT, VLC_FALSE ); add_bool( "diseqc", 0, NULL, DISEQC_TEXT, DISEQC_LONGTEXT, VLC_FALSE );
add_integer( "lnb-lof1", 10000, NULL, add_integer( "lnb-lof1", 9750, NULL, LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT, VLC_FALSE );
LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT, VLC_FALSE ); add_integer( "lnb-lof2", 10600, NULL, LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT, VLC_FALSE );
add_integer( "lnb-lof2", 10000, NULL, add_integer( "lnb-slof", 11700, NULL, LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT, VLC_FALSE );
LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT, VLC_FALSE );
add_integer( "lnb-slof", 11700, NULL,
LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT, VLC_FALSE );
add_bool( "probe", 0, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_FALSE ); add_bool( "probe", 0, NULL, PROBE_TEXT, PROBE_LONGTEXT, VLC_FALSE );
add_integer( "code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT, CODE_RATE_HP_LONGTEXT, VLC_FALSE ); add_integer( "code-rate-hp", 9, NULL, CODE_RATE_HP_TEXT, CODE_RATE_HP_LONGTEXT, VLC_FALSE );
add_integer( "code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT, CODE_RATE_LP_LONGTEXT, VLC_FALSE ); add_integer( "code-rate-lp", 9, NULL, CODE_RATE_LP_TEXT, CODE_RATE_LP_LONGTEXT, VLC_FALSE );
......
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