> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.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**

**mode** `uint16_t`

}

**custom\_payload\_size** `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.}

### `param_id_detection_gain_t`

**Members**

**gain** `int16_t`

}

**reserved** `uint16_t`

}

### `param_id_detection_engine_register_multi_sound_model_t`

**Members**

**model\_id** `uint32_t`

**model\_size** `uint32_t`

Sound model payload follows this variable}

**model** `uint8_t`

}

### `param_id_detection_engine_deregister_multi_sound_model_t`

**Members**

**model\_id** `uint32_t`

### `param_id_best_ch_enable_t`

**Members**

**enable** `uint32_t`

}

### `param_id_detection_engine_generic_event_cfg_t`

**Members**

**event\_mode** `uint32_t`

Set this field only if the event\_type variable is set to 1.}

### `event_id_detection_engine_generic_info_t`

**Members**

**status** `uint16_t`

Status sent by the Detection Engine module to the client.

**payload\_size** `uint16_t`

Actual size of the parameter data payload that follows this structure.

### `detection_event_info_header_t`

**Members**

**key\_id** `detection_engine_event_key_id_info_t`

Different key\_ids @values.

**payload\_size** `uint32_t`

Size of a specific key payload.

### `confidence_level_info_t`

**Members**

**number\_of\_confidence\_values** `uint32_t`

}

**confidence\_levels** `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.}

### `keyword_position_info_t`

**Members**

**kw\_start\_timestamp\_lsw** `uint32_t`

(in us).}

**kw\_start\_timestamp\_msw** `uint32_t`

(in us).}

**kw\_end\_timestamp\_lsw** `uint32_t`

(in us).}

**kw\_end\_timestamp\_msw** `uint32_t`

(in us).}

### `detection_timestamp_info_t`

**Members**

**detection\_timestamp\_lsw** `uint32_t`

(in milliseconds).}

**detection\_timestamp\_msw** `uint32_t`

}

### `ftrt_data_info_t`

**Members**

**ftrt\_data\_length\_in\_us** `uint32_t`

}

### `best_ch_idx_info_t`

**Members**

**best\_ch\_idx** `uint32_t`

### `voice_ui_multi_model_result_info_t`

**Members**

**num\_detected\_models** `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}

### `model_stats_t`

**Members**

**detected\_model\_id** `uint32_t`

**detected\_keyword\_id** `uint32_t`

**best\_channel\_idx** `uint32_t`

**best\_confidence\_level** `uint32_t`

**kw\_start\_timestamp\_lsw** `uint32_t`

(in us).}

**kw\_start\_timestamp\_msw** `uint32_t`

(in us).}

**kw\_end\_timestamp\_lsw** `uint32_t`

(in us).}

**kw\_end\_timestamp\_msw** `uint32_t`

(in us).}

**detection\_timestamp\_lsw** `uint32_t`

(in milliseconds).}

**detection\_timestamp\_msw** `uint32_t`

}

### `batch_drain_complete_info_t`

**Members**

**drain\_complete** `uint32_t`

Always set to 1.}

### `param_id_detection_engine_buffering_config_t`

**Members**

**hist\_buffer\_duration\_msec** `uint32_t`

The duration is limited by the memory available in the system.}

**pre\_roll\_duration\_msec** `uint32_t`

}

### `param_id_detection_engine_multi_model_buffering_config_t`

**Members**

**model\_id** `uint32_t`

**hist\_buffer\_duration\_msec** `uint32_t`

The duration is limited by the memory available in the system.}

**pre\_roll\_duration\_msec** `uint32_t`

}

### `param_id_detection_engine_per_model_reset_t`

**Members**

**model\_id** `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
```
