来自「QPSK Tuner details, for conexant chipset」· 代码 · 共 1,683 行 · 第 1/5 页

TXT
1,683
字号
            }
         }
      }
      else
      {
         /* the state machine is busy */
         return DEMOD_IS_BUSY;
      }
   }
   else
   {
      /* pass the call down to the connect function */
      return function_table[module].connect(unit, tuning, &dummy);
   }
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_demod_disconnect                                       */
/*                                                                           */
/*  PARAMETERS:  handle - the handle for which the disconnect operation is   */
/*                   requested.                                              */
/*                                                                           */
/*  DESCRIPTION: This function disconnects from a stream by calling the      */
/*               module driver to perform the actual disconnection.          */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - the system has not been initialized.  */
/*               DEMOD_NOT_CONTROLLED - the handle for which the operation   */
/*                   is requested does not have control of the device.       */
/*               The return value from the called module function.           */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEMOD_STATUS cnxt_demod_disconnect(u_int32 handle)
{
   u_int32  module, unit;

   if (!demod_initialized)
   {
      return DEMOD_UNINITIALIZED;
   }

   if ((handle & HANDLE_MAGIC_MASK) != HANDLE_MAGIC)
   {
      return DEMOD_BAD_HANDLE;
   }

   module = (handle >> 8) & 0xff;
   unit = handle & 0xff;

   if (!(handle & 0x80000000))
   {
      return DEMOD_NOT_CONTROLLED;
   }

   if (function_table[module].scan_next)
   {

      /* manipulate the state machine */
      /* change the state */
      if (change_demod_state(unit, module, CALL_DISCONNECT) == RC_OK)
      {
         /* Clear the requested tuning spec... */
         memset(&unit_state_machine_info[GLOBAL_UNIT_NUMBER].requested_tuning_spec,
                0,
                sizeof(TUNING_SPEC));

         return DEMOD_SUCCESS;
      }
      else
      {
         return DEMOD_IS_BUSY;
      }
   }
   else
   {
      /* pass the call down to the connect function */

      return function_table[module].disconnect(unit);
   }
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_demod_scan                                             */
/*                                                                           */
/*  PARAMETERS:  handle - the handle for which the scan operation is         */
/*                   requested.                                              */
/*               scanning - pointer to the SCAN_SPEC structure containing     */
/*                   parameters for the requested scan.                      */
/*                                                                           */
/*  DESCRIPTION: This function scans the carrier using the parameters        */
/*                  set in SCAN_SPEC                                         */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - the system has not been initialized.  */
/*               DEMOD_NOT_CONTROLLED - the handle for which the operation   */
/*                   is requested does not have control of the device.       */
/*               The return value from the called module function.           */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEMOD_STATUS cnxt_demod_scan(u_int32 handle, SCAN_SPEC *scanning)
{
   u_int32  module, unit;

   if (!demod_initialized)
   {
      return DEMOD_UNINITIALIZED;
   }

   if ((handle & HANDLE_MAGIC_MASK) != HANDLE_MAGIC)
   {
      return DEMOD_BAD_HANDLE;
   }

   if (!scanning)
   {
      return DEMOD_BAD_PARAMETER;
   }

   module = (handle >> 8) & 0xff;
   unit = handle & 0xff;

   if (!(handle & 0x80000000))
   {
      return DEMOD_NOT_CONTROLLED;
   }

   if (function_table[module].scan_next)
   {
      /* manipulate the state machine */

      if ((unit_state_machine_info[GLOBAL_UNIT_NUMBER].state == CONNECTED) ||
          (unit_state_machine_info[GLOBAL_UNIT_NUMBER].state == DISCONNECTED) ||
          (unit_state_machine_info[GLOBAL_UNIT_NUMBER].state == LOCK_WANTED))
      {
         /* set the TUNING_SPEC */
         unit_state_machine_info[GLOBAL_UNIT_NUMBER].scanning_spec = *scanning;
         /* change the state */
         if (change_demod_state(unit, module, INIT_SCAN) == RC_OK)
         {
            /* Clear the requested tuning spec... */
            memset(&unit_state_machine_info[GLOBAL_UNIT_NUMBER].requested_tuning_spec,
                   0,
                   sizeof(TUNING_SPEC));
            return DEMOD_SUCCESS;
         }
         else
         {
            return DEMOD_IS_BUSY;
         }
      }
      else
      {
         /* the state machine is busy */
         return DEMOD_IS_BUSY;
      }
   }
   else
   {
      /* pass the call down to the scan function */
      return function_table[module].scan(unit, scanning);
   }
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_demod_get_tuning                                       */
/*                                                                           */
/*  PARAMETERS:  handle - the handle for which the get tuning operation is   */
/*                   requested.                                              */
/*               tuning - pointer to the TUNING_SPEC structure to be filled  */
/*                   out with parameters for the current connection.         */
/*                                                                           */
/*  DESCRIPTION: This function returns the tuning parameters for the         */
/*               specified handle by calling the appropriate module function */
/*               to supply the information.                                  */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - the system has not been initialized.  */
/*               The return value from the called module function.           */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEMOD_STATUS cnxt_demod_get_tuning(u_int32 handle, TUNING_SPEC *tuning)
{
   u_int32  module, unit;

   if (!demod_initialized)
   {
      return DEMOD_UNINITIALIZED;
   }

   if ((handle & HANDLE_MAGIC_MASK) != HANDLE_MAGIC)
   {
      return DEMOD_BAD_HANDLE;
   }

   if (!tuning)
   {
      return DEMOD_BAD_PARAMETER;
   }

   module = (handle >> 8) & 0xff;
   unit = handle & 0xff;

   if (function_table[module].get_tuning != NULL)
   {
      return function_table[module].get_tuning(unit, tuning);
   }
   else
   {
      *tuning = unit_state_machine_info[GLOBAL_UNIT_NUMBER].tuning_spec;
      return DEMOD_SUCCESS;
   }
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_demod_set_callback                                     */
/*                                                                           */
/*  PARAMETERS:  handle - the handle for which the set callback operation is */
/*                   requested.                                              */
/*               callback - the function address to be used for the callback */
/*                   for this handle.                                        */
/*                                                                           */
/*  DESCRIPTION: This function records the callback function to be used for  */
/*               the specified handle and then registers its local callback  */
/*               function with the specified module.                         */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - the system has not been initialized.  */
/*               The return value from the called module function.           */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEMOD_STATUS cnxt_demod_set_callback(u_int32              handle,
                                     DEMOD_STATUS_FUNCTION *callback)
{
   u_int32  module, unit, callback_number, physical_unit;

   if (!demod_initialized)
   {
      return DEMOD_UNINITIALIZED;
   }

   if ((handle & HANDLE_MAGIC_MASK) != HANDLE_MAGIC)
   {
      return DEMOD_BAD_HANDLE;
   }

   if (!callback)
   {
      return DEMOD_BAD_PARAMETER;
   }

   module = (handle >> 8) & 0xff;            /* decode the module */
   unit = handle & 0xff;                     /* decode the relative unit number */
   callback_number = (handle >> 16) & 0x3f;  /* decode which user application number */
   physical_unit = module_base_unit[module] + unit;   /* make the unit into a flat(physical) unit number */

   callback_table[physical_unit][callback_number] = callback;
   if (function_table[module].set_callback != NULL)
   {
      return function_table[module].set_callback(unit, local_callback);
   }
   else
   {
      return DEMOD_SUCCESS;
   }
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_demod_clear_callback                                   */
/*                                                                           */
/*  PARAMETERS:  handle - the handle for which the callback function is to   */
/*                   cleared.                                                */
/*                                                                           */
/*  DESCRIPTION: This function clears the callback pointer for the specified */
/*               handle.  If there are no more user callbacks registered for */
/*               the module, the module callback is cleared.                 */
/*                                                                           */
/*  RETURNS:     DEMOD_UNINITIALIZED - the system has not been initialized.  */
/*               DEMOD_SUCCESS - the function completed successfully.        */
/*               The return value from the called module function.           */
/*                                                                           */
/*  CONTEXT:     Must be called from a non-interrupt context.                */
/*                                                                           */
/*****************************************************************************/
DEMOD_STATUS cnxt_demod_clear_callback(u_int32 handle)
{
   u_int32  module, unit, callback_number, ii, physical_unit;

   if (!demod_initialized)
   {
      return DEMOD_UNINITIALIZED;
   }

   if ((handle & HANDLE_MAGIC_MASK) != HANDLE_MAGIC)
   {
      return DEMOD_BAD_HANDLE;
   }

   module = (handle >> 8) & 0xff;
   unit = handle & 0xff;
   callback_number = (handle >> 16) & 0x3f;
   physical_unit = module_base_unit[module] + unit;   /* make the unit into a flat(physical) unit number */

   callback_table[physical_unit][callback_number] = 0;

   for (ii = 0; ii < MAX_CALLBACKS; ++ii)
   {
      if (callback_table[unit][ii])
      {
         return DEMOD_SUCCESS;
      }
   }

   if (function_table[module].clear_callback != NULL)
   {
      return function_table[module].clear_callback(unit);
   }
   else
   {
      return DEMOD_SUCCESS;
   }
}

/*****************************************************************************/
/*  FUNCTION:    cnxt_demod_get_signal_stats                                 */
/*                                                                           */
/*  PARAMETERS:  handle - the handle for which the get signal stats          */
/*                   operation is requested.                                 */
/*               signal_stats - 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        

⌨️ 快捷键说明

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