📄 stv0297.c
字号:
*pData = (gDemReg[ST0_RID_CTRL_0].value >> 4) & 0x07;
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_set_spec_inv */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* ui8SI - option of spectrum inversion. */
/* */
/* DESCRIPTION: The function sets the spectrum inversion option */
/* by programming the SPEC_INV bit of CTRL_3 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_set_spec_inv (u_int8 i2cAddr, u_int8 ui8SI)
{
if ( ui8SI == ST0_SPECTRUM_INVERSION )
{
gDemReg[ST0_RID_CTRL_3].value = gDemReg[ST0_RID_CTRL_3].value | 0x08;
}
else
{
gDemReg[ST0_RID_CTRL_3].value = gDemReg[ST0_RID_CTRL_3].value & 0xF7;
}
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_3);
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_get_spec_inv */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* pData - the pointer to the return data. 1 / 0. */
/* */
/* DESCRIPTION: The function gets the spectrum inversion option */
/* by reading the SPEC_INV bit of CTRL_3 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_get_spec_inv (u_int8 i2cAddr, u_int8 *pData)
{
st0_get_a_reg( i2cAddr, ST0_RID_CTRL_3);
if ( gDemReg[ST0_RID_CTRL_3].value & 0x08 )
{
*pData = (u_int8)ST0_SPECTRUM_INVERSION;
}
else
{
*pData = (u_int8)ST0_SPECTRUM_NORMAL;
}
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_set_itu_j83_mode */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* ui8Mode - ITU-J83 mode (ST0_ITU_J83A / ST0_ITU_J83C). */
/* */
/* DESCRIPTION: The function sets the ITU-J83 mode */
/* by programming the J83C bit of CTRL_3 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_set_itu_j83_mode (u_int8 i2cAddr, u_int8 ui8Mode)
{
if ( ui8Mode == ST0_ITU_J83C )
{
gDemReg[ST0_RID_CTRL_3].value = gDemReg[ST0_RID_CTRL_3].value | 0x01;
}
else
{
gDemReg[ST0_RID_CTRL_3].value = gDemReg[ST0_RID_CTRL_3].value & 0xFE;
}
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_3);
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_get_itu_j83_mode */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* pData - the pointer to the return data. */
/* (ST0_ITU_J83A / ST0_ITU_J83C). */
/* */
/* DESCRIPTION: The function gets the ITU-J83 mode */
/* by reading the J83C bit of CTRL_3 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_get_itu_j83_mode (u_int8 i2cAddr, u_int8 *pData)
{
st0_get_a_reg( i2cAddr, ST0_RID_CTRL_3);
if ( gDemReg[ST0_RID_CTRL_3].value & 0x01 )
{
*pData = (u_int8)ST0_ITU_J83C;
}
else
{
*pData = (u_int8)ST0_ITU_J83A;
}
return (DEM_OK);
}
/** I2C Repeater
**
** The goal of I2C repeater is to remove all unnecessary I2C messages to the
** tuner and thus improve the tuner performance. The tuner connects to pins
** SCLT and SDAT. When enabled, the repeater behaves as a fully bidirectional
** link between the main I2C bus (SCL, SDA) and the private bus (SCLT, SDAT).
** When disabled, pins SCLT and SDAT are completely isolated from the main
** I2C bus and are inactive (High Level).
**
** The I2C repeater is enabled for one single access following setting of an
** enable bit in the user registers.
**
**/
/*****************************************************************************/
/* FUNCTION: st0_start_i2c_repeater */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* */
/* DESCRIPTION: The function enables the i2c repeater for one i2c access */
/* by setting the I2CT_EN bit of CTRL_6 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_start_i2c_repeater (u_int8 i2cAddr)
{
/* set the PRGCLKDIV bits. (the division ratio for the PRGCLK clock) */
gDemReg[ST0_RID_CTRL_7].value = 0x2B;
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_7);
/* enable the I2C repeater for one I2C access. */
gDemReg[ST0_RID_CTRL_6].value = gDemReg[ST0_RID_CTRL_6].value | 0x80;
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_6);
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_stop_i2c_repeater */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* */
/* DESCRIPTION: The function disables the i2c repeater for one i2c access */
/* by clearing the I2CT_EN bit of CTRL_6 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_stop_i2c_repeater (u_int8 i2cAddr)
{
/* disable the I2C repeater for one I2C access. */
gDemReg[ST0_RID_CTRL_6].value = gDemReg[ST0_RID_CTRL_6].value & 0x7F;
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_6);
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_equ_swreset */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* */
/* DESCRIPTION: This function resets equalizer of STV0297 QAM demodulator */
/* by programming the RESET_EQL bit of CTRL_4 register. The */
/* registers EQU_0 - EQU_4 are also reinitialized. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_equ_swreset (u_int8 i2cAddr)
{
gDemReg[ST0_RID_CTRL_4].value = gDemReg[ST0_RID_CTRL_4].value | 0x01;
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_4);
gDemReg[ST0_RID_CTRL_4].value = gDemReg[ST0_RID_CTRL_4].value & 0xFE;
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_4);
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_equ_init */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* */
/* DESCRIPTION: The function initialize the Equalizer module */
/* by programming the EQU_n registers. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_equ_init (u_int8 i2cAddr)
{
/* 1: software reset the equalizer */
st0_equ_swreset (i2cAddr);
/* 2: set the u_threshold, initial_u & blind_u for the equalizer */
gDemReg[ST0_RID_EQU_0].value = gDemReg[ST0_RID_EQU_0].start;
gDemReg[ST0_RID_EQU_1].value = gDemReg[ST0_RID_EQU_1].start;
st0_set_a_reg( i2cAddr, ST0_RID_EQU_0);
st0_set_a_reg( i2cAddr, ST0_RID_EQU_1);
/* 3: clear the LMS1 & LMS2 interrupt bits */
gDemReg[ST0_RID_CTRL_2].value = gDemReg[ST0_RID_CTRL_2].value | 0x0C;
st0_set_a_reg( i2cAddr, ST0_RID_CTRL_2);
return (DEM_OK);
}
/*****************************************************************************/
/* FUNCTION: st0_set_qam_size */
/* */
/* PARAMETERS: i2cAddr - the i2c address for accessing STV0297 registers. */
/* ui8QAM - the QAM mode ( 16 / 32 / 64 / 128 / 256 ) */
/* or the auto-detect QAM mode */
/* */
/* DESCRIPTION: The function sets the QAM mode */
/* by programming the MODE_SELECT bits of EQU_0 register or */
/* the bits of CTRL_9 register. */
/* */
/* RETURNS: DEM_OK if successful, DEM_ERROR if unsuccessful. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEM_RETURN st0_set_qam_size (u_int8 i2cAddr, u_int8 ui8QAM)
{
switch (ui8QAM)
{
case ST0_QAM16:
case ST0_QAM32:
case ST0_QAM64:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -