📄 demod_dcf8722.c
字号:
/****************************************************************************/
/* CONEXANT PROPRIETARY AND CONFIDENTIAL */
/* Conexant Systems Inc. (c) 2003 - 2004 */
/* Shanghai, CHINA */
/* All Rights Reserved */
/****************************************************************************/
/*
* Filename: DEMOD_DCF8722.C
*
* Description: This file contains the module-level driver for the cable
* front-end interface for use with multi-instance demod.
*
* Author: Steven Shen
*
****************************************************************************/
/* $Header: DEMOD_DCF8722.C, 3, 2006-5-1 5:00:32, Eric (Feng) Liu$
* $Id: DEMOD_DCF8722.C,v 1.2, 2006-04-30 21:00:32Z, Eric (Feng) Liu$
****************************************************************************/
/***************************/
/* Header Files */
/***************************/
#include "stbcfg.h"
#include "hwlib.h"
#include "kal.h"
#include "retcodes.h"
#include "demod_module_api.h"
#include "iic.h"
/* to use the polling mode */
#define CABLE_INT_DISABLED
/* to disable the lock indicator */
#define CABLE_LKDT_DISABLED
/* header file of the cable dcf8722 can tuner driver */
#include "DRV_8722.h"
/* header file of the debug output function */
#include "DEBUGINF.h"
/***************************/
/* Local Label Definitions */
/***************************/
/* Define the maximum number of cable front-end units in the system */
#define MAXIMUM_NUMBER_UNITS (1)
/* Define the parameters of the tick */
#define NIM_TICK_NAME "CF_K"
#define NIM_TICK_CALLBACK (cable_tick_callback)
#define NIM_CONNECT_TIMEOUT (100)
#define NIM_MONITOR_PERIOD (200)
/* Define the parameters of the message queue */
#define NIM_MSGQ_NAME "CF_Q"
#define NIM_MSGQ_MAXIMUM (16)
/* Define the messages */
#define NIM_MSG_CONNECT (0x00000001)
#define NIM_MSG_DISCONNECT (0x00000002)
#define NIM_MSG_SCAN (0x00000003)
#define NIM_MSG_TIMEOUT (0x00000004)
#define NIM_MSG_INTERRUPT (0x00000005)
/* Define the parameters of the task */
#define NIM_TASK_MAINFUNC (cable_task_main)
/* Define the parameters of the semaphore */
#define NIM_SEM_NAME "CF_S"
/* Define the states of cable front-end units in the system */
#define NIM_NO_HARDWARE (0)
#define NIM_UNINITIALIZED (1)
#define NIM_INITIALIZED (2)
#define NIM_CONNECTING (3)
#define NIM_CONNECTED (4)
#define NIM_LOSE_LOCKED (5)
#define NIM_DISCONNECTING (6)
#define NIM_DISCONNECTED (7)
#define NIM_SCANNING (8)
#define NIM_FAILED (9)
/***************************/
/* Local Constants */
/***************************/
/* The amount of time allowed for the chip to lock and stabilise in ms */
static const u_int32 LOCK_TIMEOUT = 1000;
/* The maximum frequency offset in Hz that is allowed */
static const int32 MAX_OFFSET = 150000; /* 150 KHz */
/***************************/
/* Static Global Variables */
/***************************/
static sem_id_t gNIMSemaphore = 0;
static tick_id_t gNIMTimer = 0;
static queue_id_t gNIMQueue = 0;
static task_id_t gNIMTask = 0;
static u_int32 guLocalModule = -1;
static u_int32 guInitialized = 0;
static u_int32 guLocalUnitCount = 0; /* ONLY ONE UNIT IS SUPPORTED */
static u_int8 guTimeoutFlag = 0;
#ifndef CABLE_INT_DISABLED
static PFNISR pfnNIMPreviousIsr = 0;
static u_int32 guNIMInterrupt = 0;
static u_int8 guInterruptFlag = 0;
#endif /* CABLE_INT_DISABLED */
static int32 gTimeoutCnt=0;
static int32 gWaitingCnt=0;
static int32 gRetryCnt=0;
/* workaround the bug of 32-QAM in the auto-QAM detection mode */
static int32 gAutoQAMMode=0;
static u_int8 guNewLOCState[MAXIMUM_NUMBER_UNITS] =
{
NIM_NO_HARDWARE
};
static u_int8 guOldLOCState[MAXIMUM_NUMBER_UNITS] =
{
NIM_NO_HARDWARE
};
static u_int8 guDemodAddr[MAXIMUM_NUMBER_UNITS] =
{
#if (CABLE_TUNER_TYPE == CTT_THOMSON_TUNER)
0x38
#else
#error "ERROR! NO VALID TUNER ADDRESSS DEFINED"
#endif
};
static MODULE_STATUS_FUNCTION *gpfnCallbacks[MAXIMUM_NUMBER_UNITS];
static TUNING_SPEC gLocalTuning[MAXIMUM_NUMBER_UNITS];
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* =================================================== */
/* = ISR, TIMER, MAIN TASK OF CABLE FRONT-END DRIVER = */
/* =================================================== */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void cable_tick_callback (tick_id_t hTick, void *pUser);
void cable_task_main (void *parm);
#ifndef CABLE_INT_DISABLED
int cable_isr_handler (u_int32 uINTID, bool bIsFIQ, void *pPrevious);
/*****************************************************************************/
/* FUNCTION: cable_isr_handler */
/* */
/* PARAMETERS: uIntID - the ID of the interrupt being handled. */
/* bFIQ - flag indicating FIQ or not. */
/* pfnChain - function pointer to be filled in if interrupt */
/* chaining is required. */
/* */
/* DESCRIPTION: This function handles interrupts from the cable front-end. */
/* */
/* RETURNS: RC_ISR_HANDLED - Interrupt fully handled by this routine. */
/* RC_ISR_NOTHANDLED - Interrupt not handled by this function. */
/* (KAL should chain to the function whose pointer is */
/* stored in pfnChain). */
/* */
/* CONTEXT: Will be called from an interrupt context. */
/* */
/*****************************************************************************/
int cable_isr_handler (u_int32 uIntID, bool bFIQ, void *pfnChain)
{
u_int32 uMsg[4];
int32 iReturnCode;
/*
* Make sure that there will be no more interrupts from the cabel front-end
* until this one is fully handled (cleared).
*/
int_disable (guNIMInterrupt);
/* send a control message to the demod task to signal the interrupt. */
uMsg[0] = 0;
uMsg[1] = 0;
uMsg[2] = 0;
uMsg[3] = NIM_MSG_INTERRUPT;
iReturnCode = qu_send (gNIMQueue, uMsg);
if (RC_OK != iReturnCode)
{
guInterruptFlag = 1;
}
/* clear the interrupt status */
CLEAR_GPIO_INT_BANK (CABLE_INT_GPIO_BANK, CABLE_INT_GPIO_BIT);
/* re-enable interrupts. */
int_enable (guNIMInterrupt);
return (RC_ISR_HANDLED);
} /* cable_isr_handler */
#endif /* CABLE_INT_DISABLED */
/*****************************************************************************/
/* FUNCTION: cable_tick_callback */
/* */
/* PARAMETERS: hTick - the handle of the tick timer that expired. */
/* pUser - the user-specified parameter for the timeout. */
/* */
/* DESCRIPTION: This function handles tick timer callbacks. */
/* */
/* RETURNS: Nothing. */
/* */
/* CONTEXT: Will be called from an interrupt context. */
/* */
/*****************************************************************************/
void cable_tick_callback (tick_id_t hTick, void *pUser)
{
u_int32 uUnit = (u_int32)pUser;
u_int32 uMsg[4];
int32 iReturnCode;
/* Send a control message to the demod task to signal the timeout. */
uMsg[0] = uUnit;
uMsg[1] = 0;
uMsg[2] = 0;
uMsg[3] = (u_int32)(NIM_MSG_TIMEOUT);
iReturnCode = qu_send (gNIMQueue, uMsg);
if (RC_OK != iReturnCode)
{
guTimeoutFlag = (1 << (uUnit));
}
return;
}
/*****************************************************************************/
/* FUNCTION: cable_task_main */
/* */
/* PARAMETERS: pParam - (unused) */
/* */
/* DESCRIPTION: This function implements the acquisition task for the cable */
/* front-end driver. The task runs forever, checking an input */
/* message queue for work to do. */
/* */
/* RETURNS: Never. */
/* */
/* CONTEXT: Will be run in task context. */
/* */
/*****************************************************************************/
void cable_task_main (void *pParam)
{
int32 iReturnCode, rc;
bool bLockState;
u_int32 uRxMsg[4], uUnit, uMessage;
DEMOD_CALLBACK_DATA CallbackData;
debug_out(TL_FUNC, "CABLE TASK: Started the task\n");
while (1)
{
/* check for new message, process the message received. */
iReturnCode = qu_receive (gNIMQueue, 9000, uRxMsg);
/* if the message receive timed out, monitor current state. */
if ( iReturnCode == RC_KAL_TIMEOUT )
{
debug_out (TL_VERBOSE, "CABLE TASK: Timeout on message queue\n");
/* do nothing */
}
else if ( iReturnCode == RC_OK )
{
/* process the incoming message. */
uUnit = uRxMsg[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -