⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demod_dcf.c

📁 机顶盒解调芯片DCF8722驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
   bRetVal = dcf_get_strength(&NIMs[u32Unit]);
   
   return(DEMOD_SUCCESS);
}

/*****************************************************************************/
/*  FUNCTION:    dcf_connected_state                                         */
/*                                                                           */
/*  PARAMETERS:  u32Unit - the unit to process in the CONNECTED state.       */
/*               OldState - the previous acquisition state.                  */
/*               NewState - the new (current) acquisition state.             */
/*                                                                           */
/*  DESCRIPTION: This function implements the processing required on receipt */
/*               of an interrupt in the CONNECTED state.                     */
/*                                                                           */
/*  RETURNS:     Nothing.                                                    */
/*                                                                           */
/*  CONTEXT:     Will be run in task context.                                */
/*                                                                           */
/*****************************************************************************/
static void cnxt_dcf_tracking(u_int32 u32Unit)
{
   bool   bLocked;
   bool   bRetVal;
	 static int    n32CoutinuousLock=0;
	 
   DEMOD_CALLBACK_DATA  CallbackData;
   
   /*debug_out(TL_FUNC, "CONNECTED state processing for unit %d\n", u32Unit);*/

    /* get the strength */
   bRetVal = dcf_get_strength(&NIMs[u32Unit]);
   /* check full sync */
   dcf_get_lockstatus(&NIMs[u32Unit], &bLocked);
   
   if(bLocked == True) 
   {
   	/* event priority check: connect is of the highest priority */
      if(NIMs[u32Unit].cur_state == DCF_NIM_ACQUIRING)
         return;
   	NIMs[u32Unit].cur_state = DCF_NIM_LOCKED;
   	/*debug_out(TL_ALWAYS, "pre status in cnxt_dcf_tracking is %d\n", NIMs[u32Unit].pre_state);*/
   	switch(NIMs[u32Unit].pre_state)
   	{
   		/* FADE -> LOCKED */
   		case DCF_NIM_FADE:
   		   NIMs[u32Unit].pre_state = NIMs[u32Unit].cur_state;
   		   NIMs[u32Unit].cne = 0;
   		   if(gpfnCallbacks[u32Unit])
         {
            CallbackData.parm.type = DEMOD_DRIVER_REACQUIRED_SIGNAL;
            gpfnCallbacks[u32Unit](gu32LocalModule, u32Unit, DEMOD_CONNECT_STATUS, &CallbackData);
         }
   		   break;
   		
   		/* get signal statistics */
   		case DCF_NIM_LOCKED:
   		   n32CoutinuousLock++;
   		   NIMs[u32Unit].pre_state = NIMs[u32Unit].cur_state;
   		   if(DCF_TASK_WAIT_TIME*n32CoutinuousLock > 800)
   		   {
   		   	  n32CoutinuousLock = 0;   		   
   		      bRetVal= dcf_get_CN(&NIMs[u32Unit]);
            if(bRetVal == False)
               return;
            bRetVal = dcf_get_bert(&NIMs[u32Unit]);
            if(bRetVal == False)
               return;
         }
   		   break;
   	}
 	}
   /* handle FADE */
   else
   {
   	  n32CoutinuousLock = 0;
      NIMs[u32Unit].cne = 0;
   	  /* update signal statistics */
   	  switch(NIMs[u32Unit].pre_state)
   	  {
   		   /* FADE -> LOCKED 
   		   FADE -> FADE */
   		   case DCF_NIM_LOCKED:
   		   case DCF_NIM_FADE:
   		   
   		      /* event priority check before state switch: connect is of the highest priority */
            if(NIMs[u32Unit].cur_state == DCF_NIM_ACQUIRING)
               return;
   		      NIMs[u32Unit].cur_state = DCF_NIM_FADE;
   		      NIMs[u32Unit].pre_state = NIMs[u32Unit].cur_state;
   		      if(NIMs[u32Unit].pre_state == DCF_NIM_LOCKED)
   		      {
   		         if(gpfnCallbacks[u32Unit])
               {
                  CallbackData.parm.type = DEMOD_DRIVER_LOST_SIGNAL;
                  gpfnCallbacks[u32Unit](gu32LocalModule, u32Unit, DEMOD_CONNECT_STATUS, &CallbackData);
               }
   		         break;
   		      }
   		      if(NIMs[u32Unit].pre_state == DCF_NIM_FADE)
   		      {
   		   	     NIMs[u32Unit].cne = 0;
   		         break;
   		      }

   		   case DCF_NIM_FAILED:
   		      /* event priority check before state switch: connect is of the highest priority */
            if(NIMs[u32Unit].cur_state == DCF_NIM_ACQUIRING)
               return;
   		      NIMs[u32Unit].cur_state = DCF_NIM_FAILED;
   		      NIMs[u32Unit].pre_state = NIMs[u32Unit].cur_state;
            NIMs[u32Unit].cne = 0;
   		      break;

   		   default:
   		      break;
   	  }
   }
}

/*****************************************************************************/
/*  FUNCTION:    dcf_task                                                    */
/*                                                                           */
/*  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.                                */
/*                                                                           */
/*****************************************************************************/
static void dcf_task(void *pParam)
{

   int                   ii;

   /*debug_out(TL_FUNC, "CABLE TASK: Started the task\n");*/
   while(1)
   {
      /* delay for idle */
      dcf_wait(DCF_TASK_WAIT_TIME);

      /* get the semaphore that protects the control task */
      if (RC_OK != sem_get(gsemDCFTask, KAL_WAIT_FOREVER))
      {
          return;
      }
	  
      for(ii = 0; ii < gu32LocalUnitCount; ii++)
      {
         /*debug_out(TL_ALWAYS, "DEMOD TASK, current status=%d\n", NIMs[ii].cur_state);*/
      	switch(NIMs[ii].cur_state)
      	{
            case DCF_NIM_ACQUIRING:
            case DCF_NIM_FADE:
            case DCF_NIM_FAILED:
               cnxt_dcf_acquire(ii);
               break;
      		   
            case DCF_NIM_LOCKED:
               cnxt_dcf_tracking(ii);
               break;
      		
            default:
            break;
         }
      }
      
      /* put the unused semaphore */
      sem_put(gsemDCFTask);
   } /* endwhile (1) */
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_dcf_get_unit_type                                      */
/*                                                                           */
/*  PARAMETERS:  u32Unit - unit number for which type information is         */
/*                         requested.                                        */
/*                                                                           */
/*               pUnitType - pointer to the DEMOD_NIM_TYPE variable to be    */
/*                           filled out.                                     */
/*                                                                           */
/*  DESCRIPTION: This function returns information about the type of the     */
/*               unit that is the subject of the request.                    */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - this module has not been initialized. */
/*               DEMOD_BAD_UNIT - the unit number is not valid.              */
/*               DEMOD_BAD_PARAMETER - there is a bad parameter.             */
/*               DEMOD_SUCCESS - the function completed successfully.        */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_get_unit_type (u_int32 u32Unit, DEMOD_NIM_TYPE *pUnitType)
{
   if(!gu32Initialized)
   {
      return (DEMOD_UNINITIALIZED);
   }
   
   if(NIMs[u32Unit].cur_state == DCF_NIM_UNINITIALIZED)
   {
      return (DEMOD_BAD_UNIT);
   }
   
   if(NULL == pUnitType)
   {
      return(DEMOD_BAD_PARAMETER);
   }
   
   *pUnitType = DEMOD_NIM_CABLE;
   return(DEMOD_SUCCESS);
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_dcf_ioctl                                              */
/*                                                                           */
/*  PARAMETERS:  u32Unit - the unit number for which the ioctl operation is  */
/*                         requested.                                        */
/*               eType - the type of ioctl operation requested.              */
/*               pData - pointer to the DEMOD_IOCTL_TYPE structure that      */
/*                       contains data for the operation or will be filled   */
/*                       out with data by the operation.                     */
/*                                                                           */
/*  DESCRIPTION: This function implements various module-specific control or */
/*               status functions.                                           */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - this module has not been initialized. */
/*               DEMOD_BAD_UNIT - the unit number is not valid.              */
/*               DEMOD_UNIMPLEMENTED - The IOCTL is not used in this driver  */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_ioctl (u_int32 u32Unit, DEMOD_IOCTL_TYPE eType, void *pData)
{
   if(!gu32Initialized)
   {
      return(DEMOD_UNINITIALIZED);
   }
   
   if(NIMs[u32Unit].cur_state == DCF_NIM_UNINITIALIZED)
   {
      return(DEMOD_BAD_UNIT);
   }
   
   return(DEMOD_UNIMPLEMENTED);
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_dcf_connect                                            */
/*                                                                           */
/*  PARAMETERS:  u32Unit - the unit number for which the connect operation   */
/*                         is requested.                                     */
/*               pTuning - pointer to the TUNING_SPEC structure containing   */
/*                         parameters for the requested connection.          */
/*               pTimeLimit - timeout value (ms) to be filled-out. if it's   */
/*                            OK for state machine to do it, allow plenty.   */
/*                                                                           */
/*  DESCRIPTION: This function connects to a stream by tuning the interface  */
/*               to the requested specification.                             */
/*                                                                           */
/*  RETURNS:     DEMOD_SUCCESS - the function completed successfully.        */
/*               DEMOD_UNINITIALIZED - this module has not been initialized. */
/*               DEMOD_BAD_UNIT      - the unit is not valid.                */
/*               DEMOD_BAD_PARAMETER - there is a bad parameter.             */
/*               DEMOD_ERROR - there has been an error.                      */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static DEMOD_STATUS cnxt_dcf_connect(u_int32 u32Unit, TUNING_SPEC *pTuning, u_int32 *pTimeLimit)
{ 
   /* signal will be tuned only when NIM is initialized */
   if(!gu32Initialized)
   {
      return(DEMOD_UNINITIALIZED);
   }
   /*debug_out(TL_ALWAYS, "DEMOD CONNECT, current status=%d\n", NIMs[0].cur_state);*/
   
   /* exit the previous acquiring at first!!! */
   while(NIMs[0].cur_state == DCF_NIM_ACQUIRING)
   {
      /* 1, exit the previous acquisition */
      NIMs[0].exit_acquring = True;
      dcf_wait(20);
   }

   /* 2, start new acquistion */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -