Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
Toggle table of contents sidebar

# Control

The control API for the generated DSP.

These functions can be executed on any thread which is on the same tile as the generated DSP threads.

Enums

enum adsp_control_status_t

  Control status.

  Values:

  enumerator ADSP_CONTROL_SUCCESS

    Command succesfully executed.

  enumerator ADSP_CONTROL_BUSY

    Stage has not yet processed the command, call again.

Functions

void adsp_controller_init(adsp_controller_t *ctrl, adsp_pipeline_t *pipeline)

  Create a DSP controller instance for a particular pipeline.

  Parameters:

    - ctrl – The controller instance to initialise.

    - pipeline – The DSP pipeline that will be controlled with this controller.

adsp_control_status_t adsp_read_module_config(

  adsp_controller_t *ctrl,
  adsp_stage_control_cmd_t *cmd,

)

  Initiate a read command by passing in an intialised adsp_stage_control_cmd_t.

  Must be called repeatedly with the same cmd until ADSP_CONTROL_SUCCESS is returned. If the caller abandons the attempt to read before SUCCESS is returned then this will leave the stage in a state where it can never be read from again.

  Parameters:

    - ctrl – An instance of adsp_controller_t which has been initialised to control the DSP pipeline.

    - cmd – An initialised adsp_stage_control_cmd_t.

  Returns:

    adsp_control_status_t

adsp_control_status_t adsp_write_module_config(

  adsp_controller_t *ctrl,
  adsp_stage_control_cmd_t *cmd,

)

  Initiate a write command by passing in an initialised adsp_stage_control_cmd_t.

  Must be called repeatedly with the same cmd until ADSP_CONTROL_SUCCESS is returned.

  Parameters:

    - ctrl – An instance of adsp_controller_t which has been initialised to control the DSP pipeline.

    - cmd – An initialised adsp_stage_control_cmd_t.

  Returns:

    adsp_control_status_t

void adsp_control_xscope_register_probe()

  Default xscope setup function.

  Sets up a single xscope probe with name ADSP, type XSCOPE_CONTINUOUS, and datatype XSCOPE_UINT. Should be called within xscope_user_init().

chanend_t adsp_control_xscope_init()

  Creates an xscope chanend and connects it to the host. Must be called on the same tile as the DSP pipeline.

  Returns:

    chanend_t

adsp_control_status_t adsp_control_xscope_process(

  chanend_t c_xscope,
  adsp_controller_t *ctrl,

)

  Process an xscope chanend containing a control command from the host.

  Parameters:

    - c_xscope – A chanend which has been connected to the host.

    - ctrl – An instance of adsp_controller_t which has been initialised to control the DSP pipeline.

  Returns:

    adsp_control_status_t

void adsp_control_xscope(adsp_pipeline_t *adsp)

  Creates an xscope handler thread for ADSP control.

  Handles all xscope traffic and calls to adsp_read_module_config and adsp_write_module_config. If the application already uses xscope, do not call this function; instead, identify host-to-device packets by the ADSP header and pass them to adsp_control_xscope_process manually.

  Parameters:

    - adsp – The DSP pipeline that will be controlled with this xscope thread.

struct adsp_stage_control_cmd_t
  #include <adsp_control.h>

  The command to execute. Specifies which stage, what command and contains the buffer to read from or write to.

  Public Members

  uint8_t instance_id

    The ID of the stage to target. Consider setting the label parameter in the pipeline definition to ensure that a usable identifier gets generated for using with control.

  uint8_t cmd_id

    “See the generated cmds.h for the available commands. Make sure to use a command which is supported for the target stage.

  uint16_t payload_len

    Length of the command in bytes.

  void *payload

    The buffer. Must be set to a valid array of size payload_len before calling the read or write functions.

struct adsp_controller_t
  #include <adsp_control.h>

  Object used to control a DSP pipeline.

  As there may be multiple threads attempting to interact with the DSP pipeline at the same time, a separate instance of adsp_controller_t must be used by each to ensure that control can proceed safely.

  Initialise each instance of adsp_controller_t with adsp_controller_init.

  Private Members

  module_instance_t *modules
  size_t num_modules