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

📄 demod_dcf8722.c

📁 机顶盒解调芯片DCF8722驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
   
   if (NULL == pTuning)
   {
      return (DEMOD_BAD_PARAMETER);
   }
   
   /* get the semaphore that protects the NIM operation */
   if (RC_OK != sem_get(gNIMSemaphore, KAL_WAIT_FOREVER))
   {
      return (DEMOD_ERROR);
   }
   
   /* get the parameters of the current tuning signal */
   if ( dcf872x_get_tuning(uUnit, pTuning) )
   {
      /* Release the semaphore */
      sem_put(gNIMSemaphore);
      return (DEMOD_ERROR);
   }
   else
   {
      /* Release the semaphore */
      sem_put(gNIMSemaphore);
      return (DEMOD_SUCCESS);
   }
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_c_set_callback                                         */
/*                                                                           */
/*  PARAMETERS:  uUnit - the unit number for which the callback is to be set */
/*               pfnCallback - the function address to be used for the       */
/*                             callback for this unit.                       */
/*                                                                           */
/*  DESCRIPTION: This function sets the callback pointer for the specified   */
/*               unit.                                                       */
/*                                                                           */
/*  RETURNS:     DEMOD_SUCCESS - the function completed successfully.        */
/*               DEMOD_UNINITIALIZED - this module has not been initialized. */
/*               DEMOD_BAD_PARAMETER - there is a bad parameter.             */
/*               DEMOD_BAD_UNIT - the unit number is not valid.              */
/*               DEMOD_ERROR - there has been an error.                      */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static DEMOD_STATUS cnxt_c_set_callback (
   u_int32                 uUnit,
   MODULE_STATUS_FUNCTION  *pfnCallback
)
{
   if (!guInitialized)
   {
      return (DEMOD_UNINITIALIZED);
   }
   
   if (NIM_NO_HARDWARE == guNewLOCState[uUnit])
   {
      return (DEMOD_BAD_UNIT);
   }
   
   if (NULL == pfnCallback)
   {
      return (DEMOD_BAD_PARAMETER);
   }
   
   /* save the callback function pointer */
   gpfnCallbacks[uUnit] = pfnCallback;
   return (DEMOD_SUCCESS);
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_c_clear_callback                                       */
/*                                                                           */
/*  PARAMETERS:  uUnit - the unit number for which the callback is to be     */
/*                       cleared.                                            */
/*                                                                           */
/*  DESCRIPTION: This function clears the callback pointer for the specified */
/*               unit.                                                       */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - this module has not been initialized. */
/*               DEMOD_BAD_PARAMETER - there is a bad parameter.             */
/*               DEMOD_BAD_UNIT - the unit number is not valid.              */
/*               DEMOD_ERROR - there has been an error.                      */
/*               DEMOD_SUCCESS - the function completed successfully.        */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static DEMOD_STATUS cnxt_c_clear_callback (u_int32 uUnit)
{
   if (!guInitialized)
   {
      return (DEMOD_UNINITIALIZED);
   }
   
   if (NIM_NO_HARDWARE == guNewLOCState[uUnit])
   {
      return (DEMOD_BAD_UNIT);
   }
   
   /* clear the callback function pointer */
   gpfnCallbacks[uUnit] = 0;
   return (DEMOD_SUCCESS);
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_c_get_signal_stats                                     */
/*                                                                           */
/*  PARAMETERS:  uUnit - the unit number for which the get signal stats      */
/*                       operation is requested.                             */
/*               pSignalStats - pointer to the SIGNAL_STATS structure to be  */
/*                       filled out with parameters for the specified unit.  */
/*                                                                           */
/*  DESCRIPTION: This function returns the signal statistics for the         */
/*               specified unit.                                             */
/*                                                                           */
/*  RETURNS:     DEMOD_SUCCESS - If all went well.                           */
/*               DEMOD_UNINITIALIZED - this module has not been initialized. */
/*               DEMOD_BAD_PARAMETER - there is a bad parameter.             */
/*               DEMOD_BAD_UNIT - the unit number is not valid.              */
/*               DEMOD_ERROR - there has been an error.                      */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
static DEMOD_STATUS cnxt_c_get_signal_stats (u_int32 uUnit, SIGNAL_STATS *pSignalStats)
{
   float       fCNE;
   
   if (!guInitialized)
   {
      return (DEMOD_UNINITIALIZED);
   }
   
   if (NIM_NO_HARDWARE == guNewLOCState[uUnit])
   {
      return (DEMOD_BAD_UNIT);
   }
   
   if (NULL == pSignalStats)
   {
      return (DEMOD_BAD_PARAMETER);
   }
   
   /* Fill stats (points to pSignalStats) with the status information */
   pSignalStats->type = DEMOD_NIM_CABLE;
   fCNE = ((float)(gCNimCfg.DemodCNE) * 100.0 / 40.0);
   pSignalStats->stats.c_signal.signal_quality  = (int)(fCNE);
   /* We could not get the AGC(s) values of Thomson cable front-end.  */
   /* so now the signal strength is equal to the signal quality.      */
   pSignalStats->stats.c_signal.signal_strength = gCNimCfg.SignalStrength;
   pSignalStats->stats.c_signal.rs_uncorrected  = gCNimCfg.DemodBERTerr;
   pSignalStats->stats.c_signal.rs_total        = gCNimCfg.DemodBERTnb;
   
   return (DEMOD_SUCCESS);
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_c_get_lock_status                                      */
/*                                                                           */
/*  PARAMETERS:  uUnit - the unit number for which the get lock status       */
/*                       operation is requested.                             */
/*               pLocked - pointer to the boolean to be filled out indicated */
/*                       in locked/not locked for the specified unit.        */
/*                                                                           */
/*  DESCRIPTION: This function returns the lock status for the specified     */
/*               unit.                                                       */
/*                                                                           */
/*  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_c_get_lock_status (u_int32 uUnit, bool *pLocked)
{
   if (!guInitialized)
   {
      return (DEMOD_UNINITIALIZED);
   }
   
   if (NIM_NO_HARDWARE == guNewLOCState[uUnit])
   {
      return (DEMOD_BAD_UNIT);
   }
   
   if (NULL == pLocked)
   {
      return (DEMOD_BAD_PARAMETER);
   }
   
   /* return the current lock status of the unit. */
   if (NIM_CONNECTED == guNewLOCState[uUnit])
   {
      *pLocked = TRUE;
   }
   else
   {
      *pLocked = FALSE;
   }
   
   return (DEMOD_SUCCESS);
}


/*****************************************************************************/
/*  FUNCTION:    cnxt_c_scan_next                                            */
/*                                                                           */
/*  PARAMETERS:  uUnit - the unit number for which the scan_next operation   */
/*                       is requested.                                       */
/*               pScan - pointer to the SCAN_SPEC structure                  */
/*                                                                           */
/*  DESCRIPTION: This function manipulates the current TUNING_SPEC inside    */
/*               the SCAN_SPEC to the next scan parameters.                  */
/*                                                                           */
/*  RETURNS:     FALSE - OK                                                  */
/*               TRUE  - Scan passed the end or invalid bandwidth            */
/*                                                                           */
/*****************************************************************************/
/*
static bool cnxt_c_scan_next (u_int32 uUnit, SCAN_SPEC *pScan)
{
   if (!guInitialized)
   {
      return (FALSE);
   }
   
   if (NIM_NO_HARDWARE == guNewLOCState[uUnit])
   {
      return (FALSE);
   }
   
   if (NULL == pScan)
   {
      return (FALSE);
   }
   
   // TODO
   return (TRUE);
}
*/

/*****************************************************************************/
/*  FUNCTION:    cnxt_c_demod_reacquire                                      */
/*                                                                           */
/*  PARAMETERS:  pOriginal - a pointer to the tuning spec that was           */
/*                           originally tuned to.                            */
/*               pActual   - a pointer to the actual TUNING_SPEC that the    */
/*                           demod is tuned to.                              */
/*                                                                           */
/*  DESCRIPTION: This function compaires the two TUNING_SPEC's and decides   */
/*               if it is required to tune again to the actual TUNING_SPEC.  */
/*                                                                           */
/*  RETURNS:     TRUE - we need to re tune to the actual TUNING_SPEC.        */
/*               FALSE - we do NOT need to tune.                             */
/*                                                                           */
/*****************************************************************************/
/*
static bool cnxt_c_reacquire (TUNING_SPEC *pOriginal, TUNING_SPEC *pActual)
{
   int32    offset;
   
   if ( pOriginal->tune.nim_cable_tune.frequency >
        pActual->tune.nim_cable_tune.frequency
   )
   {
      offset = (pOriginal->tune.nim_cable_tune.frequency) -
               (pActual->tune.nim_cable_tune.frequency);
   }
   else
   {
      offset = (pActual->tune.nim_cable_tune.frequency) -

⌨️ 快捷键说明

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