📄 demod_hamaro.c
字号:
#endif
static void process_set_pol_message(int unit, NIM_SATELLITE_POLARISATION *data)
{
if ( 0 == data )
{
trace_new( TL_ERROR, "Hamaro demod received bad data parameter for SET_LNB_POLARIZATION\n" );
pol_state = POL_FAILED;
return;
}
else
{
if( cnxt_lnb_set_polarization( &NIMs[unit], *(NIM_SATELLITE_POLARISATION *)data ) != DEMOD_SUCCESS )
{
pol_state = POL_FAILED;
return;
}
}
pol_state = POL_COMPLETE;
return;
}
static void process_set_tone_message(int unit, bool *data)
{
if ( 0 == data )
{
trace_new( TL_ERROR, "Hamaro demod received bad data parameter for SET_LNB_TONE\n" );
tone_state = TONE_FAILED;
return;
}
else
{
if( cnxt_lnb_set_tone_enable(&NIMs[unit], *(bool *)data) != DEMOD_SUCCESS )
{
tone_state = TONE_FAILED;
return;
}
}
tone_state = TONE_COMPLETE;
return;
}
/*****************************************************************************/
/* FUNCTION: NIM_Wait */
/* */
/* PARAMETERS: nim - pointer to the NIM structure of the NIM requesting */
/* the delay. */
/* waitms - the number of milliseconds to delay. */
/* */
/* DESCRIPTION: This function is used by the NIM-specific code to provide */
/* an OS dependent method to delay a specified number of */
/* milliseconds. */
/* */
/* RETURNS: TRUE to indicate success. */
/* */
/* CONTEXT: Must be called from non-interrupt context. */
/* */
/*****************************************************************************/
static BOOL NIM_Wait( NIM *nim, int waitms )
{
task_time_sleep( waitms );
return TRUE;
}
/*****************************************************************************/
/* FUNCTION: SBWrite */
/* */
/* PARAMETERS: demod_handle - handle of demod for write request (San Diego */
/* code handle, not multi-instance demod handle). */
/* reg_addr - the register offset to be written. */
/* data - the data value to be written. */
/* status - pointer to status value filled in at completion */
/* (0 for success, non-0 for failure). */
/* */
/* DESCRIPTION: This function writes the specified value to the specified */
/* register offset of the specified demod unit. */
/* */
/* RETURNS: Nothing. */
/* */
/* CONTEXT: Must be called from non-interrupt context. */
/* */
/*****************************************************************************/
static void SBWrite( unsigned long demod_handle, unsigned char reg_addr, unsigned long data, unsigned long *status )
{
unsigned char serial_bus_addr;
unsigned char page_addr;
volatile unsigned short *sts_reg_addr;
//unsigned long sts_reg_addr;
unsigned long reg_value = 0;
if ( 0 == status )
{
trace_new( TL_ERROR, "Bad status parameter to Hamaro SBWrite!\n" );
error_log( ERROR_WARNING | RC_SDM_BADVAL );
return;
}
if( demod_handle & STS_APPLY_BASE_ADDRESS )
{
/* It's a Scan The Sky handle */
reg_value = data;
/* extract page address from demod handle */
page_addr = (demod_handle>>11) & 0x3;
/* 0x304e1000 is the base address for the 32-bit STS memory access */
/* copy page address to bit position [9:8] of the 32-bit memory address */
/* address bit 0 on the Hamaro side can be wired to bit 10 on the ARM side. */
/* address bit 1 on the Hamaro side can be wired to bit 11 on the ARM side. */
sts_reg_addr = (unsigned short *)(STS_BASE_ADDRESS|(page_addr << 8)|(reg_addr & 0xfc)|((reg_addr & 0x3)<<10));
*sts_reg_addr = reg_value;
*status = 0;
return;
}
else if ( demod_handle & 0xfffeff00 )
{
trace_new( TL_ERROR, "Bad demod_handle parameter to Hamaro SBWrite!\n" );
error_log( ERROR_WARNING | RC_SDM_BADVAL );
*status = 1;
return;
}
#if (HAMARO_INCLUDE_RATTLER || HAMARO_INCLUDE_VIPER)
if (((demod_handle & 0x000000FF) == HAMARO_CX24128_I2C_ADD1) || ((demod_handle & 0x000000FF) == HAMARO_CX24128_I2C_ADD2))
{
/* get serial bus address from demod handle */
serial_bus_addr = (unsigned char)(demod_handle & 0x000000FF);
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
if ((demod_access_method == DEMOD_HYBRID) || (demod_access_method == DEMOD_REGISTER))
{
CNXT_SET( PLL_PAD_FAST_CTRL_REG, PLL_FAST_CTRL_DEMOD_CONNECT_SEL_MASK,
PLL_FAST_CTRL_DEMOD_CONNECT_I2C );
}
#endif
/* if writing the tuner register, always use the I2C mode. */
*status = !iicWriteIndexedReg( serial_bus_addr, reg_addr, data, demod_iic_bus );
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
if ((demod_access_method == DEMOD_HYBRID) || (demod_access_method == DEMOD_REGISTER))
{
CNXT_SET( PLL_PAD_FAST_CTRL_REG, PLL_FAST_CTRL_DEMOD_CONNECT_SEL_MASK,
PLL_FAST_CTRL_DEMOD_CONNECT_ASX );
}
#endif
}
else
{
#endif
/* perform the write */
if (( demod_access_method == DEMOD_IIC)
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
|| ((demod_access_method == DEMOD_HYBRID) &&
(reg_addr == 0 || reg_addr == 0x23 || reg_addr == 0x33 || reg_addr == 0x34 ||
reg_addr == 0x39 || reg_addr == 0x3a || reg_addr == 0x3b || reg_addr == 0x3c ||
reg_addr == 0x43 || reg_addr == 0x44))
#endif
)
{
/* get serial bus address from demod handle */
serial_bus_addr = (unsigned char)(demod_handle & 0x000000FF);
/* determine DEMOD_A or DEMOD_B register address offset. */
if ( (demod_handle >> 16) != 0 )
reg_addr |= 0x80; /* add 128 to register address. */
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
if ( demod_access_method == DEMOD_HYBRID )
{
CNXT_SET( PLL_PAD_FAST_CTRL_REG, PLL_FAST_CTRL_DEMOD_CONNECT_SEL_MASK,
PLL_FAST_CTRL_DEMOD_CONNECT_I2C );
}
#endif
*status = !iicWriteIndexedReg( serial_bus_addr, reg_addr, data, demod_iic_bus );
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
if ( demod_access_method == DEMOD_HYBRID )
{
CNXT_SET( PLL_PAD_FAST_CTRL_REG, PLL_FAST_CTRL_DEMOD_CONNECT_SEL_MASK,
PLL_FAST_CTRL_DEMOD_CONNECT_ASX );
}
#endif
}
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
else if ( demod_access_method == DEMOD_REGISTER || demod_access_method == DEMOD_HYBRID )
{
*(LPREG)INTERNAL_DEMOD_REG_TO_ASX_ADDR(reg_addr) = data;
*status = 0; /* indicate success */
}
#endif
else
{
trace_new( TL_ERROR, "Bad demod access method in Hamaro SBWrite!\n" );
*status = 1; /* indicate failure */
}
#if (HAMARO_INCLUDE_RATTLER || HAMARO_INCLUDE_VIPER)
}
#endif
}
/*****************************************************************************/
/* FUNCTION: SBRead */
/* */
/* PARAMETERS: demod_handle - handle of demod for read request (San Diego */
/* code handle, not multi-instance demod handle). */
/* reg_addr - the register offset to be read. */
/* status - pointer to status value filled in at completion */
/* (0 for success, non-0 for failure). */
/* */
/* DESCRIPTION: This function reads from the specified register offset of */
/* the specified demod unit and returns the value read. */
/* */
/* RETURNS: The value read from the device. */
/* */
/* CONTEXT: Must be called from non-interrupt context. */
/* */
/*****************************************************************************/
static unsigned long SBRead( unsigned long demod_handle, unsigned char reg_addr, unsigned long *status )
{
unsigned char serial_bus_addr;
unsigned long reg_value = 0;
//unsigned long sts_reg_addr = 0;
volatile unsigned short *sts_reg_addr=0;
unsigned char page_addr;
if ( 0 == status )
{
trace_new( TL_ERROR, "Bad status parameter to Hamaro SBRead!\n" );
error_log( ERROR_WARNING | RC_SDM_BADVAL );
return 0;
}
if( demod_handle & STS_APPLY_BASE_ADDRESS )
{
/* It's a Scan The Sky handle */
/* extract page address from demod handle */
page_addr = (demod_handle>>11) & 0x3;
/* 0x304e1000 is the base address for the 32-bit STS memory access */
/* copy page address to bit position [9:8] of the 32-bit memory address */
/* address bit 0 on the Hamaro side can be wired to bit 10 on the ARM side. */
/* address bit 1 on the Hamaro side can be wired to bit 11 on the ARM side. */
sts_reg_addr = (unsigned short *)(STS_BASE_ADDRESS |(page_addr << 8)|(reg_addr & 0xfc)|((reg_addr & 0x3)<<10));
reg_value = *sts_reg_addr;
//reg_value = CNXT_GET(sts_reg_addr, 0xFFFF);
*status = 0;
return reg_value;
}
else if ( demod_handle & 0xfffeff00 )
{
trace_new( TL_ERROR, "Bad demod_handle parameter to Hamaro SBRead!\n" );
error_log( ERROR_WARNING | RC_SDM_BADVAL );
*status = 1;
return 0;
}
#if (HAMARO_INCLUDE_RATTLER || HAMARO_INCLUDE_VIPER)
if (((demod_handle & 0x000000FF) == HAMARO_CX24128_I2C_ADD1) || ((demod_handle & 0x000000FF) == HAMARO_CX24128_I2C_ADD2))
{
/* get serial bus address from demod handle */
serial_bus_addr = (unsigned char)(demod_handle & 0x000000FF);
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
if ((demod_access_method == DEMOD_HYBRID) || (demod_access_method == DEMOD_REGISTER))
{
CNXT_SET( PLL_PAD_FAST_CTRL_REG, PLL_FAST_CTRL_DEMOD_CONNECT_SEL_MASK,
PLL_FAST_CTRL_DEMOD_CONNECT_I2C );
}
#endif
/* if reading the tuner register, always use the I2C mode. */
*status = !iicReadIndexedReg( serial_bus_addr, reg_addr, (unsigned char*)®_value, demod_iic_bus );
#if (INTERNAL_DEMOD == INTERNAL_COBRA_LIKE)
if ((demod_access_method == DEMOD_HYBRID) || (demod_access_method == DEMOD_REGISTER))
{
CNXT_SET( PLL_PAD_FAST_CTRL_REG, PLL_FAST_CTRL_DEMOD_CONNECT_SEL_MASK,
PLL_FAST_CTRL_DEMOD_CONNECT_ASX );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -