> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Detection CMN API

> This file contains common parameters for listen libraries.

**Header:** `spf/api/modules/detection_cmn_api.h`

## Structures

### `param_id_detection_engine_config_t`

**Members**

<ParamField path="mode" type="uint16_t">
  }
</ParamField>

<ParamField path="custom_payload_size" type="uint16_t">
  If custom\_payload\_size is not 4-byte aligned, the caller must fill padding bytes to ensure that the entire calibration is 4-byte aligned.

  Immediately following this variable is the custom configuration payload of size custom\_payload\_size.}
</ParamField>

### `param_id_detection_gain_t`

**Members**

<ParamField path="gain" type="int16_t">
  }
</ParamField>

<ParamField path="reserved" type="uint16_t">
  }
</ParamField>

### `param_id_detection_engine_register_multi_sound_model_t`

**Members**

<ParamField path="model_id" type="uint32_t" />

<ParamField path="model_size" type="uint32_t">
  Sound model payload follows this variable}
</ParamField>

<ParamField path="model" type="uint8_t">
  }
</ParamField>

### `param_id_detection_engine_deregister_multi_sound_model_t`

**Members**

<ParamField path="model_id" type="uint32_t" />

### `param_id_best_ch_enable_t`

**Members**

<ParamField path="enable" type="uint32_t">
  }
</ParamField>

### `param_id_detection_engine_generic_event_cfg_t`

**Members**

<ParamField path="event_mode" type="uint32_t">
  Set this field only if the event\_type variable is set to 1.}
</ParamField>

### `event_id_detection_engine_generic_info_t`

**Members**

<ParamField path="status" type="uint16_t">
  Status sent by the Detection Engine module to the client.
</ParamField>

<ParamField path="payload_size" type="uint16_t">
  Actual size of the parameter data payload that follows this structure.
</ParamField>

### `detection_event_info_header_t`

**Members**

<ParamField path="key_id" type="detection_engine_event_key_id_info_t">
  Different key\_ids @values.
</ParamField>

<ParamField path="payload_size" type="uint32_t">
  Size of a specific key payload.
</ParamField>

### `confidence_level_info_t`

**Members**

<ParamField path="number_of_confidence_values" type="uint32_t">
  }
</ParamField>

<ParamField path="confidence_levels" type="uint8_t">
  This array is of size DETECTION\_ENGINE\_MAX\_REGISTERED\_MODELS. Each element is 1 byte long.

  Assuming N keywords and M active user models are included in the model, the first N elements of this parameter correspond to the confidence of N keywords. The N+1 to N+M elements control the confidence level of the M active user model. Each element maps confidence values for entries (keyword or user specific keyword) whose order is specified in the sound model.}
</ParamField>

### `keyword_position_info_t`

**Members**

<ParamField path="kw_start_timestamp_lsw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="kw_start_timestamp_msw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="kw_end_timestamp_lsw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="kw_end_timestamp_msw" type="uint32_t">
  (in us).}
</ParamField>

### `detection_timestamp_info_t`

**Members**

<ParamField path="detection_timestamp_lsw" type="uint32_t">
  (in milliseconds).}
</ParamField>

<ParamField path="detection_timestamp_msw" type="uint32_t">
  }
</ParamField>

### `ftrt_data_info_t`

**Members**

<ParamField path="ftrt_data_length_in_us" type="uint32_t">
  }
</ParamField>

### `best_ch_idx_info_t`

**Members**

<ParamField path="best_ch_idx" type="uint32_t" />

### `voice_ui_multi_model_result_info_t`

**Members**

<ParamField path="num_detected_models" type="uint32_t">
  If 3 models are registered with STAGE1\_SVA5 and detected happened for 2 models, then this value will be set to 2 Following this will be num\_detected\_models number of model\_stats\_t type payloads each containing the result statistics for each detected model}
</ParamField>

### `model_stats_t`

**Members**

<ParamField path="detected_model_id" type="uint32_t" />

<ParamField path="detected_keyword_id" type="uint32_t" />

<ParamField path="best_channel_idx" type="uint32_t" />

<ParamField path="best_confidence_level" type="uint32_t" />

<ParamField path="kw_start_timestamp_lsw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="kw_start_timestamp_msw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="kw_end_timestamp_lsw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="kw_end_timestamp_msw" type="uint32_t">
  (in us).}
</ParamField>

<ParamField path="detection_timestamp_lsw" type="uint32_t">
  (in milliseconds).}
</ParamField>

<ParamField path="detection_timestamp_msw" type="uint32_t">
  }
</ParamField>

### `batch_drain_complete_info_t`

**Members**

<ParamField path="drain_complete" type="uint32_t">
  Always set to 1.}
</ParamField>

### `param_id_detection_engine_buffering_config_t`

**Members**

<ParamField path="hist_buffer_duration_msec" type="uint32_t">
  The duration is limited by the memory available in the system.}
</ParamField>

<ParamField path="pre_roll_duration_msec" type="uint32_t">
  }
</ParamField>

### `param_id_detection_engine_multi_model_buffering_config_t`

**Members**

<ParamField path="model_id" type="uint32_t" />

<ParamField path="hist_buffer_duration_msec" type="uint32_t">
  The duration is limited by the memory available in the system.}
</ParamField>

<ParamField path="pre_roll_duration_msec" type="uint32_t">
  }
</ParamField>

### `param_id_detection_engine_per_model_reset_t`

**Members**

<ParamField path="model_id" type="uint32_t" />

## Type Definitions

### `param_id_detection_engine_config_t`

```cpp theme={null}
typedef struct param_id_detection_engine_config_t param_id_detection_engine_config_t
```

### `param_id_detection_gain_t`

```cpp theme={null}
typedef struct param_id_detection_gain_t param_id_detection_gain_t
```

### `param_id_detection_engine_register_multi_sound_model_t`

```cpp theme={null}
typedef struct param_id_detection_engine_register_multi_sound_model_t param_id_detection_engine_register_multi_sound_model_t
```

### `param_id_detection_engine_deregister_multi_sound_model_t`

```cpp theme={null}
typedef struct param_id_detection_engine_deregister_multi_sound_model_t param_id_detection_engine_deregister_multi_sound_model_t
```

### `param_id_best_ch_enable_t`

```cpp theme={null}
typedef struct param_id_best_ch_enable_t param_id_best_ch_enable_t
```

### `param_id_detection_engine_generic_event_cfg_t`

```cpp theme={null}
typedef struct param_id_detection_engine_generic_event_cfg_t param_id_detection_engine_generic_event_cfg_t
```

### `event_id_detection_engine_generic_info_t`

```cpp theme={null}
typedef struct event_id_detection_engine_generic_info_t event_id_detection_engine_generic_info_t
```

### `detection_engine_event_key_id_info_t`

IDs for keyword index information and confidence value information in the detection engine generic event payload.

```cpp theme={null}
typedef enum detection_engine_event_key_id_info_t detection_engine_event_key_id_info_t
```

### `param_id_detection_engine_buffering_config_t`

```cpp theme={null}
typedef struct param_id_detection_engine_buffering_config_t param_id_detection_engine_buffering_config_t
```

### `param_id_detection_engine_multi_model_buffering_config_t`

```cpp theme={null}
typedef struct param_id_detection_engine_multi_model_buffering_config_t param_id_detection_engine_multi_model_buffering_config_t
```

### `param_id_detection_engine_per_model_reset_t`

```cpp theme={null}
typedef struct param_id_detection_engine_per_model_reset_t param_id_detection_engine_per_model_reset_t
```

## Enumerations

### `detection_engine_event_key_id_info_t`

IDs for keyword index information and confidence value information in the detection engine generic event payload.

#### Values

| Name                                      | Value         | Description                                                               |
| ----------------------------------------- | ------------- | ------------------------------------------------------------------------- |
| `KEY_ID_CONFIDENCE_LEVELS_INFO`           | = 0x2000      | Confidence levels detected per sound model.                               |
| `KEY_ID_KWD_POSITION_INFO`                |               | Keyword start and end timestamps.                                         |
| `KEY_ID_TIMESTAMP_INFO`                   |               | Detetion timestamp info.                                                  |
| `KEY_ID_FTRT_DATA_INFO`                   |               | FTRT Data length in the circular buffer.                                  |
| `KEY_ID_BEST_CH_IDX_INFO`                 |               | Best Ch Idx detected by the algorithm                                     |
| `KEY_ID_VOICE_UI_MULTI_MODEL_RESULT_INFO` |               | Multi Model Detection Engine result info.                                 |
| `KEY_ID_BATCH_DRAIN_COMPLETE`             |               | Batch drain complete notification for Force Recognition in batching mode. |
| `KEY_ID_MAX_VALUE`                        | =  0x7FFFFFFF | Maxium supported value for KEY\_ID.                                       |

## Macros

### `DETECTION_ENGINE_MAX_REGISTERED_MODELS`

```c theme={null}
#define DETECTION_ENGINE_MAX_REGISTERED_MODELS 20
```

### `DETECTION_STATUS_SUCCESS`

Status (Detected) sent to notify that the detection engine has detected a keyword.

```c theme={null}
#define DETECTION_STATUS_SUCCESS 0
```

### `DETECTION_STATUS_FAILURE`

Status (Rejected) sent to notify the that a detection module has rejected a keyword.

```c theme={null}
#define DETECTION_STATUS_FAILURE 1
```

### `MAX_MODELS_SUPPORTED`

```c theme={null}
#define MAX_MODELS_SUPPORTED 8
```

### `MAX_KEYWORDS_SUPPORTED`

```c theme={null}
#define MAX_KEYWORDS_SUPPORTED 8
```

### `PARAM_ID_DETECTION_ENGINE_CONFIG`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_CONFIG 0x08001049
```

### `PARAM_ID_DETECTION_GAIN`

```c theme={null}
#define PARAM_ID_DETECTION_GAIN 0x0800104B
```

### `PARAM_ID_DETECTION_ENGINE_SOUND_MODEL`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_SOUND_MODEL 0x0800104C
```

### `PARAM_ID_DETECTION_ENGINE_REGISTER_MULTI_SOUND_MODEL`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_REGISTER_MULTI_SOUND_MODEL 0x0800124E
```

### `PARAM_ID_DETECTION_ENGINE_DEREGISTER_MULTI_SOUND_MODEL`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_DEREGISTER_MULTI_SOUND_MODEL 0x08001250
```

### `PARAM_ID_BEST_CH_ENABLE`

```c theme={null}
#define PARAM_ID_BEST_CH_ENABLE 0x08001065
```

### `PARAM_ID_DETECTION_ENGINE_GENERIC_EVENT_CFG`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_GENERIC_EVENT_CFG 0x0800104E
```

### `EVENT_ID_DETECTION_ENGINE_GENERIC_INFO`

```c theme={null}
#define EVENT_ID_DETECTION_ENGINE_GENERIC_INFO 0x0800104F
```

### `PARAM_ID_DETECTION_ENGINE_RESET`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_RESET 0x08001051
```

### `PARAM_ID_DETECTION_ENGINE_BUFFERING_CONFIG`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_BUFFERING_CONFIG 0x08001044
```

### `PARAM_ID_DETECTION_ENGINE_MULTI_MODEL_BUFFERING_CONFIG`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_MULTI_MODEL_BUFFERING_CONFIG 0x0800124F
```

### `PARAM_ID_DETECTION_ENGINE_PER_MODEL_RESET`

```c theme={null}
#define PARAM_ID_DETECTION_ENGINE_PER_MODEL_RESET 0x080014ED
```
