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

📄 demod_dcf8722.c

📁 机顶盒解调芯片DCF8722驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
               (pOriginal->tune.nim_cable_tune.frequency);
   }
   
   if ( offset > MAX_OFFSET )
   {
      return (TRUE);
   }
   else
   {
      return (FALSE);
   }
}
*/

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*               =========================================                   */
/*               = ENTRY POINT OF CABLE FRONT-END DRIVER =                   */
/*               =========================================                   */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*****************************************************************************/
/*  FUNCTION:    cnxt_cable_demod_init                                       */
/*                                                                           */
/*  PARAMETERS:  uModule      - the module designation to be used by this    */
/*                              driver in subsequent callbacks.              */
/*                                                                           */
/*               pNumberUnits - the pointer to an integer to be filled with  */
/*                              the total number of units in this module.    */
/*                                                                           */
/*               pfnFTable    - the pointer to the DEMOD_FTABLE structure to */
/*                              be filled out with function pointers for the */
/*                              module.                                      */
/*                                                                           */
/*  DESCRIPTION: This function initializes the module and returns a count of */
/*               units in the module and the function table for module       */
/*               functions.                                                  */
/*                                                                           */
/*  RETURNS:     DEMOD_SUCCESS - the function completed successfully.        */
/*               DEMOD_INITIALIZED - this module has been initialized.       */
/*               DEMOD_BAD_PARAMETER - there is a bad parameter.             */
/*               DEMOD_NO_HARDWARE - there is no NIM hardware in the system. */
/*               DEMOD_ERROR - An error was received from a call             */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEMOD_STATUS cnxt_cable_demod_init (
   u_int32        uModule,
   u_int32        *pNumberUnits,
   DEMOD_FTABLE   *pfnFTable
)
{
   int32          ii;
   
   debug_out (TL_FUNC, "CABLE INIT: Entered initialization uModule 0x%02X\n", uModule);
   
   if (guInitialized)
   {
      debug_out (TL_ERROR, "CABLE INIT: Already been initialized\n");
      return (DEMOD_INITIALIZED);
   }
   
   /**************************************************************************/
   /*   check whether the input parameters are valid.
    */
   if (NULL == pNumberUnits)
   {
      debug_out (TL_ERROR, "CABLE INIT: Bad parameter - pNumberUnits\n");
      return (DEMOD_BAD_PARAMETER);
   }
   
   if (NULL == pfnFTable)
   {
      debug_out (TL_ERROR, "CABLE INIT: Bad parameter - pfnFTable\n");
      return (DEMOD_BAD_PARAMETER);
   }
   
   /**************************************************************************/
   /*   check whether the NIM hardwares to be initialized are valid.
    */
   guLocalUnitCount = 0;
   
   /* Is there a GPIO pin used to reset the cable front-end? */
   #if (defined CABLE_RESET_DISABLED)
   /*
    * If the driver is for the NIM board on the Bronco IRD,
    * no GPIO pin is used to reset the NIM board.
    */
   #else /* CABLE_RESET_DISABLED is not defined. */
   /*
    * If the driver is for the Cable Front End module on the PuDong IRD,
    * we should set the RESET GPIO pin to HIGH level to get the Cable Front
    * End module out of reset.
    */
#if (CHIP_NAME == BRAZOS)
   DRIVE_GPIO_HIGH_BANK (CABLE_RST_GPIO_BANK, CABLE_RST_GPIO_BIT);
#endif /* CABLE_RESET_DISABLED */
#endif /* CABLE_RESET_DISABLED */
   
   for (ii=0; ii<(MAXIMUM_NUMBER_UNITS); ii++)
   {
      if (FALSE == iicAddressTest(guDemodAddr[ii], I2C_BUS_CABLE_FE, 0))
      {
         debug_out (TL_INFO, "CABLE INIT: Unit %d is not found at i2c addr 0x%03X\n", ii, guDemodAddr[ii]);
         guOldLOCState[ii] = guNewLOCState[ii];
         guNewLOCState[ii] = NIM_NO_HARDWARE;
      }
      else
      {
         debug_out (TL_INFO, "CABLE INIT: Unit %d is found at i2c addr 0x%03X\n", ii, guDemodAddr[ii]);
         guOldLOCState[ii] = guNewLOCState[ii];
         guNewLOCState[ii] = NIM_UNINITIALIZED;
         guLocalUnitCount++;
      }
   }
   
   if (0 == guLocalUnitCount)
   {
      debug_out (TL_ERROR, "CABLE INIT: No hardware is detected\n");
      return (DEMOD_NO_HARDWARE);
   }
   
   /**************************************************************************/
   /*   allocate system resources (semaphore, queue, task ...) for the driver.
    */
   
   /* create the semaphore to be used to protect the cable front-end */
   gNIMSemaphore = sem_create(1, NIM_SEM_NAME);
   if (gNIMSemaphore == (sem_id_t)(0))
   {
      debug_out (TL_ERROR, "CABLE INIT: Can't create semaphore\n");
      return (DEMOD_ERROR);
   }
   
   /* create the tick timer to be used to timeout state transitions. */
   gNIMTimer = tick_create (NIM_TICK_CALLBACK, (void *)0, NIM_TICK_NAME);
   if (gNIMTimer == (tick_id_t)(0))
   {
      debug_out (TL_ERROR, "CABLE INIT: Can't create tick timer\n");
      return (DEMOD_ERROR);
   }
   
   /* create the message queue to be used to communicate with the DEMOD task */
   gNIMQueue = qu_create (NIM_MSGQ_MAXIMUM, NIM_MSGQ_NAME);
   if (gNIMQueue == (queue_id_t)(0))
   {
      debug_out (TL_ERROR, "CABLE INIT: Can't create message queue\n");
      return (DEMOD_ERROR);
   }
   
   /* create the task to be used to process the messages from the DEMOD ISR */
   gNIMTask = task_create (NIM_TASK_MAINFUNC, NULL, NULL, (NIM_TASK_STK_SIZE),
                           (NIM_TASK_PRIORITY), (NIM_TASK_NAME));
   if (gNIMTask == (task_id_t)(0))
   {
      debug_out (TL_ERROR, "CABLE INIT: Can't create task\n");
      return (DEMOD_ERROR);
   }
   
   /**************************************************************************/
   /*   initialize the found NIM interfaces.
    */
   for (ii=0; ii<(MAXIMUM_NUMBER_UNITS); ii++)
   {
      /* ignore all lost NIM interfaces */
      if (NIM_NO_HARDWARE == guNewLOCState[ii])
      {
         continue;
      }
      /* get the semaphore that protects the NIM operation */
      if (RC_OK != sem_get(gNIMSemaphore, KAL_WAIT_FOREVER))
      {
         debug_out (TL_ERROR, "CABLE INIT: Can't get the semaphore\n");
         return (DEMOD_ERROR);
      }
      
      /* clear the callback function pointer */
      gpfnCallbacks[ii] = 0;
      
      /* initialize the Cable NIM */
      if ( dcf872x_init(ii) != DRV_OK )
      {
         debug_out (TL_ERROR, "CABLE INIT: Unknown type of the cable front-end\n");
         return (DEMOD_ERROR);
      }
      
      /* update the state */
      guOldLOCState[ii] = guNewLOCState[ii];
      guNewLOCState[ii] = NIM_INITIALIZED;
      
      /* release the semaphore */
      sem_put(gNIMSemaphore);
      debug_out (TL_INFO, "CABLE INIT: Initialized unit 0x%02X\n", ii);
   }
   
   /* Which method is used to detect the events, POLLING or INTERRUPT? */
   #if (defined CABLE_INT_DISABLED)
   /* the POLLING method is used.   */
   #else /* CABLE_INT_DISABLED is not defined */
   /* the INTERRUPT method is used. */
   {
      int32          rc;
      
      /* set a GPIO pin as a interrupt source for the cable front-end driver */
      guNIMInterrupt = (u_int32)(INT_CABLE_NIM);
      /* claim a GPIO pin and set it up for input, interrupt on both edges. */
      MAKE_GPIO_INPUT_BANK (CABLE_INT_GPIO_BANK, CABLE_INT_GPIO_BIT);
      SET_GPIO_INT_EDGE_BANK (CABLE_INT_GPIO_BANK, CABLE_INT_GPIO_BIT, BOTH_EDGES);
      /* register the ISR handler for the interrupt */
      rc = int_register_isr (guNIMInterrupt, (PFNISR)cable_isr_handler,
                             FALSE, FALSE, (PFNISR *)&pfnNIMPreviousIsr);
      if (RC_OK != rc)
      {
         debug_out (TL_ERROR, "CABLE INIT: Can't register the interrupt handler\n");
         return (DEMOD_ERROR);
      }
      /* enable the interrupt */
      rc = int_enable (guNIMInterrupt);
      if (RC_OK != rc)
      {
         debug_out (TL_ERROR, "CABLE INIT: Can't enable the GPIO interrupt\n");
         return (DEMOD_ERROR);
      }
   }
   #endif /* CABLE_INT_DISABLED */
   
   /* Is a hardware lock indicator used to indicate the current lock status? */
   #if (defined CABLE_LKDT_DISABLED)
   /* no hardware lock indicator */
   #else /* CABLE_LKDT_DISABLED is not defined */
   /* during the driver initialization, turn off the lock indicator. */
   CABLE_LKDT_TURN_OFF (CABLE_LKDT_GPIO_BANK, CABLE_LKDT_GPIO_BIT);
   #endif
   
   /* initialize the functions table for this module type */
   pfnFTable->unit_type      = CABLE_UNIT_TYPE_FUNC;
   pfnFTable->ioctl          = CABLE_IOCTL_FUNC;
   pfnFTable->connect        = CABLE_CONNECT_FUNC;
   pfnFTable->disconnect     = CABLE_DISCONNECT_FUNC;
   pfnFTable->get_signal     = CABLE_GET_SIGNAL_FUNC;
   pfnFTable->get_lock       = CABLE_GET_LOCK_FUNC;
   pfnFTable->scan           = CABLE_SCAN_FUNC;
   pfnFTable->get_tuning     = CABLE_GET_TUNING_FUNC;
   pfnFTable->set_callback   = CABLE_SET_CALLBACK_FUNC;
   pfnFTable->clear_callback = CABLE_CLEAR_CALLBACK_FUNC;
   pfnFTable->scan_next      = CABLE_SCAN_NEXT_FUNC;
   pfnFTable->re_acquire     = CABLE_RE_ACQUIRE_FUNC;
   /* how many units are supported -- MUST BE ONLY ONE */
   *pNumberUnits = guLocalUnitCount;
   guLocalModule = uModule;
   guInitialized = 1;
   
   debug_out (TL_FUNC, "CABLE INIT: Finished initialization uModule 0x%02X\n", uModule);
   return (DEMOD_SUCCESS);
}


/****************************************************************************
 * Modifications:
 * $Log: 
 *  5    mpeg      1.4         5/26/04 3:12:04 AM     Steven Shen     CR(s) 
 *        9022 9023 : The DEMOD_DCF8722 driver version 1.20. Fix some bugs and 
 *        Add the support of getting the signal strength.
 *  4    mpeg      1.3         5/21/04 2:52:58 AM     Steven Shen     CR(s) 
 *        9273 9274 : Remove the task information into taskprio.h and 
 *        ucosconf.h.
 *  3    mpeg      1.2         5/20/04 3:35:08 AM     Steven Shen     CR(s) 
 *        9254 9255 : Support the Auto-QAM detection mode.
 *  2    mpeg      1.1         4/4/04 12:58:43 AM     Steven Shen     CR(s) 
 *        8674 8675 : Added support for auto-detect spectrum inversion (both 
 *        NORMAL and INVERTED).
 *  1    mpeg      1.0         3/15/04 10:30:36 AM    Matt Korte      CR(s) 
 *        8566 : Initial version of Thomson Cable Tuner/Demod
 * $
 *
 ****************************************************************************/

⌨️ 快捷键说明

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