📄 lnb.c
字号:
else
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_a;
tone_enable = FALSE;
}
break;
/* For an orbital position LNB, the resulting frequency is just the
difference between the transponder frequency and the LNB frequency
for the matching orbital position. The 22 KHz signalling is set on
if the requested orbital position specifies it, set off otherwise. */
case LNB_ORBITAL_POSITION:
if ( tuning->tune.nim_satellite_tune.orbital_position ==
lnb_parameters.orbital_position_a )
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_a;
if ( lnb_parameters.orbital_22khz_a )
{
tone_enable = TRUE;
}
else
{
tone_enable = FALSE;
}
}
else if ( tuning->tune.nim_satellite_tune.orbital_position ==
lnb_parameters.orbital_position_b )
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_b;
if ( lnb_parameters.orbital_22khz_b )
{
tone_enable = TRUE;
}
else
{
tone_enable = FALSE;
}
}
else
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_c;
if ( lnb_parameters.orbital_22khz_c )
{
tone_enable = TRUE;
}
else
{
tone_enable = FALSE;
}
}
break;
/* For a manual LNB, the resulting frequency is just the input
frequency. */
case LNB_MANUAL:
result_frequency = (int)tuning->tune.nim_satellite_tune.frequency;
break;
/* For a frequency stacking LNB such as Dish Network's DishPro LNB,
both left and right polarizations are available on the same
cable without signalling. One polarization occupies part of the
bandwidth and the other occupies a different region of the
spectrum. In this case, there are 2 effective LNB frequencies
with the choice of LNB being made depending upon the polarization
of the transponder to be tuned. */
case LNB_FREQUENCY_STACK:
if((tuning->tune.nim_satellite_tune.polarisation == M_HORIZONTAL) ||
(tuning->tune.nim_satellite_tune.polarisation == M_RIGHT))
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_a;
tone_enable = FALSE;
}
else
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_b;
tone_enable = FALSE;
}
break;
default:
#if RTOS != NOOS
error_log( ERROR_WARNING | RC_SDM_BADVAL );
#endif /* RTOS != NOOS */
break;
}
/* Set the appropriate LNB settings if not a manually controlled LNB. */
if ( lnb_parameters.type != LNB_MANUAL )
{
cnxt_lnb_set_polarization( pNIM,
tuning->tune.nim_satellite_tune.polarisation);
cnxt_lnb_set_tone_enable( pNIM, tone_enable );
}
/* In case the result frequency comes
out negative, put it back positive. */
if ( result_frequency < 0 )
{
result_frequency = -result_frequency;
}
/* Multiply to convert KHz to Hz */
result_frequency *= 1000;
*freq = (u_int32)result_frequency;
return DEMOD_SUCCESS;
}
/*****************************************************************************/
/* FUNCTION: cnxt_lnb_init */
/* */
/* PARAMETERS: pNIM - pointer to the Hamaro driver NIM structure for the */
/* NIM the LNB code is being initialized for. */
/* */
/* DESCRIPTION: This function initializes LNB signalling for the NIM. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* DEMOD_ERROR - there was an error in a low level driver */
/* function. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEMOD_STATUS cnxt_lnb_init( NIM *pNIM )
{
/* Set the PIO that controls the direction of the 22KHz signal for output
as the initial setting. Any DiSEqC input will need to change it. */
#if PIO_LNB_22KHZ_DIRECTION != GPIO_INVALID
/*
* !!! HACK ALERT !!!
* WARNING!!!!! Hack required to keep from setting this PIO on a
* Bronco1. When Bronco1 boards disappear, so should this hack. (PIO
* setting should become conditional only upon value of
* PIO_LNB_22KHZ_DIRECTION != GPIO_INVALID.)
* !!! HACK ALERT !!!
*/
#if I2C_CONFIG_EEPROM_ADDR != NOT_PRESENT
{
extern int ConfigurationValid;
extern CONFIG_TABLE config_table;
if ( ConfigurationValid &&
( config_table.board_type != 0x00 ||
((config_table.board_type == 0x00) &&
(config_table.board_rev != 0x01)) ) )
{
cnxt_gpio_set_output_level( PIO_LNB_22KHZ_DIRECTION, TRUE );
}
}
#endif
/*
* !!! HACK ALERT !!!
* !!! HACK ALERT !!!
*/
#endif
/* Set up directional control for the PIO controlling LNB enable. */
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
/* No direction control necessary. */
#else
/* Hamaro GPIO4 is the enable for the external LNB signal generator;
set as an output. */
if ( RegisterWrite( pNIM, CX24130_GPIO4DIR, 1 ) != True )
{
#if RTOS != NOOS
{
int api_error;
trace_new( TL_ERROR,
"Hamaro demod failed to set direction of LNB signal enable"
" (GPIO4).\n" );
trace_new( TL_ERROR, "File: %s, line: %d\n",
API_GetErrorFilename(pNIM),
API_GetErrorLineNumber(pNIM) );
api_error = API_GetLastError( pNIM );
trace_new( TL_ERROR, "Error %d, %s\n", api_error,
API_GetErrorMessage(pNIM, (APIERRNO)api_error) );
}
#endif /* RTOS != NOOS */
return DEMOD_ERROR;
}
#endif
#if (LNBH21PD_ENABLED == TRUE)
write_lnb21( 0x00 );
#endif
/* Actually enable LNB output unless initialization with output disabled is
requested. */
#ifndef LNB_INITIALLY_DISABLED
cnxt_lnb_set_output_enable( pNIM, TRUE );
#endif
return DEMOD_SUCCESS;
}
DEMOD_STATUS cnxt_lnb_set_output_enable( NIM *pNIM, bool enable )
{
/* Set up the LNB enable signal. It is different for internal/external. */
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
#if (LNBH21PD_ENABLED == TRUE)
{
u_int8 bData;
read_lnb21( &bData );
bData &= ~0x04;
if (enable) bData |= 0x04 ;
write_lnb21( bData );
}
#else
/* LNB enable signal is driven from the PIO expander; set to 1 to
enable, 0 to disable. */
cnxt_gpio_set_output_level( PIO_LNB_ENABLE, enable );
#endif
lnb_state.enabled = enable;
#else
/* Hamaro GPIO4 is the enable for the external LNB signal generator;
set to 1 to enable, 0 to disable. */
if ( RegisterWrite( pNIM, CX24130_GPIO4VAL, enable ) == True )
{
lnb_state.enabled = enable;
}
else
{
#if RTOS != NOOS
{
int api_error;
trace_new( TL_ERROR,
"Hamaro demod failed to write to LNB signal enable"
" (GPIO4).\n" );
trace_new( TL_ERROR, "File: %s, line: %d\n",
API_GetErrorFilename(pNIM),
API_GetErrorLineNumber(pNIM) );
api_error = API_GetLastError( pNIM );
trace_new( TL_ERROR, "Error %d, %s\n", api_error,
API_GetErrorMessage(pNIM, (APIERRNO)api_error) );
}
#endif /* RTOS != NOOS */
return DEMOD_ERROR;
}
#endif
return DEMOD_SUCCESS;
}
DEMOD_STATUS cnxt_lnb_get_output_enable( NIM *pNIM, bool *enable )
{
*enable = lnb_state.enabled;
return DEMOD_SUCCESS;
}
DEMOD_STATUS cnxt_lnb_set_polarization( NIM *pNIM,
NIM_SATELLITE_POLARISATION polarization)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -