📄 lnb.c
字号:
/****************************************************************************/
/* CONEXANT PROPRIETARY AND CONFIDENTIAL */
/* Conexant Systems Inc. (c) 2002-2004 */
/* Austin, TX */
/* All Rights Reserved */
/****************************************************************************/
/*
* Filename: lnb.c
*
* Description: This file contains the implementation of the driver support
* code to deal with setting the LNB for the Hamaro family of
* demod chips (CX24121 and CX24130).
*
* Author: Billy Jackman
*
****************************************************************************/
/*
$Id: lnb.c,v 1.18, 2004-10-14 20:52:58Z, Bobby Bradford$
*
****************************************************************************/
#include "stbcfg.h"
#include "basetype.h"
#include "demod_types.h"
#include "trace.h"
#include "retcodes.h"
#include "kal.h"
#include "gpio.h"
#include "hamaro.h"
#include "lnb.h"
extern void FCopy(char *pDest, char *pSrc, u_int32 len);
/* I2C LNB Setup Macros */
#if defined (I2C_ADDR_LNBH21PD) && (I2C_ADDR_LNBH21PD != NOT_PRESENT)
#define LNBH21PD_ENABLED (TRUE)
#else
#define LNBH21PD_ENABLED (FALSE)
#endif
#if defined (I2C_ADDR_LNBISL6421) && (I2C_ADDR_LNBISL6421 != NOT_PRESENT)
#define LNBISL6421_ENABLED (TRUE)
#else
#define LNBISL6421_ENABLED (FALSE)
#endif
/* Sanity Check */
#if (LNBH21PD_ENABLED == TRUE) && (LNBISL6421_ENABLED == TRUE)
#error "Cannot Have two I2C LNB Devices"
#endif
#if (LNBH21PD_ENABLED == TRUE) || (LNBISL6421_ENABLED == TRUE)
#if RTOS != NOOS
#include "iic.h"
#else
#include "miic.h"
#endif
#endif
LNB_SETTINGS lnb_parameters;
static struct {
bool enabled;
NIM_SATELLITE_POLARISATION polarization;
bool tone_enabled;
} lnb_state = { FALSE };
/* Some handy tags for trace level specifications. */
#define TL_ALWAYS (TRACE_LEVEL_ALWAYS | TRACE_DMD)
#define TL_ERROR (TRACE_LEVEL_ALWAYS | TRACE_DMD)
#define TL_INFO (TRACE_LEVEL_3 | TRACE_DMD)
#define TL_FUNC (TRACE_LEVEL_2 | TRACE_DMD)
#define TL_VERBOSE (TRACE_LEVEL_1 | TRACE_DMD)
#if (LNBH21PD_ENABLED == TRUE)
/*****************************************************************************/
/* FUNCTION: write_lnb21 */
/* */
/* PARAMETERS: byte to write the the lnb control register */
/* */
/* DESCRIPTION: This function will abstract the implementation of the iic */
/* interface used to setup the lnb device. */
/* */
/* RETURNS: None */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static void write_lnb21 ( u_int8 uData )
{
#if (RTOS != NOOS)
iicWriteReg(I2C_ADDR_LNBH21PD, uData, I2C_BUS_LNBH21PD);
#else
MIIC_Write(I2C_ADDR_LNBH21PD, &uData, 1, I2C_BUS_LNBH21PD);
#endif
}
/*****************************************************************************/
/* FUNCTION: read_lnb21 */
/* */
/* PARAMETERS: pointer to location to store the lnb control register data */
/* */
/* DESCRIPTION: This function will abstract the implementation of the iic */
/* interface used to setup the lnb device. */
/* */
/* RETURNS: None */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static void read_lnb21 ( u_int8 *puData )
{
#if (RTOS != NOOS)
iicReadReg(I2C_ADDR_LNBH21PD, puData, I2C_BUS_LNBH21PD);
#else
MIIC_Read(I2C_ADDR_LNBH21PD, puData, 1, I2C_BUS_LNBH21PD);
#endif
}
#endif /* #if (LNBH21PD_ENABLED == TRUE) */
#if (LNBISL6421_ENABLED == TRUE)
/*****************************************************************************/
/* FUNCTION: write_lnb6421 */
/* */
/* PARAMETERS: byte to write the the lnb control register */
/* */
/* DESCRIPTION: This function will abstract the implementation of the iic */
/* interface used to setup the lnb device. */
/* */
/* RETURNS: None */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static void write_lnb6421 ( u_int8 uData )
{
#if (RTOS != NOOS)
iicWriteReg(I2C_ADDR_LNBISL6421, uData, I2C_BUS_LNBISL6421);
#else
MIIC_Write(I2C_ADDR_LNBISL6421, &uData, 1, I2C_BUS_LNBISL6421);
#endif
}
#if 0 /* Not used for now, but leave here for completeness */
/*****************************************************************************/
/* FUNCTION: read_lnb6421 */
/* */
/* PARAMETERS: pointer to location to store the lnb control register data */
/* */
/* DESCRIPTION: This function will abstract the implementation of the iic */
/* interface used to setup the lnb device. */
/* */
/* RETURNS: None */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
static void read_lnb6421 ( u_int8 *puData )
{
#if (RTOS != NOOS)
iicReadReg(I2C_ADDR_LNBISL6421, puData, I2C_BUS_LNBISL6421);
#else
MIIC_Read(I2C_ADDR_LNBISL6421, puData, 1, I2C_BUS_LNBISL6421);
#endif
}
#endif
#endif /* #if (LNBH21PD_ENABLED == TRUE) */
/*****************************************************************************/
/* FUNCTION: cnxt_lnb_set_parameters */
/* */
/* PARAMETERS: lnb - pointer to the LNB_SETTINGS structure defining the */
/* LNB settings to be used. */
/* */
/* DESCRIPTION: This function makes a local copy of the LNB settings to be */
/* used in future tuning operations. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEMOD_STATUS cnxt_lnb_set_parameters( LNB_SETTINGS *lnb )
{
FCopy ( (char *)&lnb_parameters, (char *)lnb, sizeof ( LNB_SETTINGS ) );
return DEMOD_SUCCESS;
}
/*****************************************************************************/
/* FUNCTION: cnxt_lnb_get_parameters */
/* */
/* PARAMETERS: lnb - pointer to the LNB_SETTINGS structure to be filled in */
/* with a copy of the LNB settings in use. */
/* */
/* DESCRIPTION: This function fills in the LNB_SETTINGS structure from the */
/* local copy. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEMOD_STATUS cnxt_lnb_get_parameters( LNB_SETTINGS *lnb )
{
FCopy ( (char *)lnb, (char *)&lnb_parameters, sizeof ( LNB_SETTINGS ) );
return DEMOD_SUCCESS;
}
/*****************************************************************************/
/* FUNCTION: cnxt_set_lnb */
/* */
/* PARAMETERS: pNIM - pointer to the Hamaro driver NIM structure for the */
/* NIM the LNB is to be set for. */
/* tuning - pointer to the TUNING_SPEC structure containing */
/* specification of the current tuning operation. */
/* freq - pointer to the tuner frequency resulting from the */
/* tuning request and current LNB settings. */
/* */
/* DESCRIPTION: This function fills in the freq parameter based on the */
/* contents of the tuning parameter and current LNB settings. */
/* This calculates the tuner frequency based on the LNB LO */
/* frequency and the transponder frequency. If the LNB is */
/* configured as LNB_MANUAL, the input frequency is the tuner */
/* frequency, so it is just copied. This function sets the */
/* LNB signalling voltage and tone as appropriate. */
/* */
/* RETURNS: DEMOD_SUCCESS - the function completed successfully. */
/* */
/* CONTEXT: Must be called from a non-interrupt context. */
/* */
/*****************************************************************************/
DEMOD_STATUS cnxt_set_lnb( NIM *pNIM, TUNING_SPEC *tuning, u_int32 *freq )
{
int32 result_frequency;
bool tone_enable = FALSE;
switch ( lnb_parameters.type )
{
/* For a single band LNB, the resulting frequency is just the difference
between the transponder frequency and the LNB frequency. In all
cases, 22 KHz signalling is off for a single band LNB. */
case LNB_SINGLE_FREQUENCY:
result_frequency = (int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_a;
tone_enable = FALSE;
break;
/* For a dual band LNB, the resulting frequency is the difference
between the transponder frequency and either the low band or the high
band LNB frequency, determined by the switch frequency. The 22 KHz
signalling is set on to select high band, off to select low band. */
case LNB_DUAL_FREQUENCY:
if ( tuning->tune.nim_satellite_tune.frequency >=
lnb_parameters.lnb_switch )
{
result_frequency =
(int)tuning->tune.nim_satellite_tune.frequency -
(int)lnb_parameters.lnb_b;
tone_enable = TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -