1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019 Intel Corporation. All rights reserved.
4  *
5  * Author: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
6  */
7 
8 #ifndef __USER_DETECT_TEST_H__
9 #define __USER_DETECT_TEST_H__
10 
11 #include <stdint.h>
12 
13 /** IPC blob types */
14 #define SOF_DETECT_TEST_CONFIG	0
15 #define SOF_DETECT_TEST_MODEL	1
16 
17 struct sof_detect_test_config {
18 	uint32_t size;
19 
20 	/** synthetic system load settings */
21 	uint32_t load_mips;
22 	uint32_t load_memory_size;
23 	/** time in ms after which detection is activated */
24 	uint32_t preamble_time;
25 
26 	/** activation right shift, determines the speed of activation */
27 	uint16_t activation_shift;
28 
29 	/** sample width in bits - ignored with IPC4 */
30 	int16_t sample_width;
31 
32 	/** activation threshold */
33 	int32_t activation_threshold;
34 
35 	/** default draining size in bytes */
36 	uint32_t drain_req;
37 
38 	/** reserved for future use */
39 	uint32_t reserved[1];
40 } __packed;
41 
42 uint16_t test_keyword_get_sample_valid_bytes(struct comp_dev *dev);
43 
44 uint32_t test_keyword_get_detected(struct comp_dev *dev);
45 void test_keyword_set_detected(struct comp_dev *dev, uint32_t detected);
46 
47 #if CONFIG_KWD_NN_SAMPLE_KEYPHRASE
48 const int16_t *test_keyword_get_input(struct comp_dev *dev);
49 
50 int16_t test_keyword_get_input_byte(struct comp_dev *dev, uint32_t index);
51 int16_t test_keyword_get_input_elem(struct comp_dev *dev, uint32_t index);
52 int test_keyword_set_input_elem(struct comp_dev *dev, uint32_t index, int16_t val);
53 
54 size_t test_keyword_get_input_size(struct comp_dev *dev);
55 void test_keyword_set_input_size(struct comp_dev *dev, size_t input_size);
56 #endif
57 
58 uint32_t test_keyword_get_drain_req(struct comp_dev *dev);
59 void test_keyword_set_drain_req(struct comp_dev *dev, uint32_t drain_req);
60 
61 void detect_test_notify(const struct comp_dev *dev);
62 
63 /** used for binary blob size sanity checks */
64 #define SOF_DETECT_TEST_MAX_CFG_SIZE sizeof(struct sof_detect_test_config)
65 
66 #endif /* __USER_DETECT_TEST_H__ */
67