1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2022 Intel Corporation. All rights reserved.
4  *
5  * Author: Adrian Bonislawski <adrian.bonislawski@intel.com>
6  */
7 
8 /**
9  * \file audio/aria/aria.h
10  * \brief Aria component header file
11  * \authors Adrian Bonislawski <adrian.bonislawski@intel.com>
12  */
13 
14 #ifndef __SOF_AUDIO_ARIA_H__
15 #define __SOF_AUDIO_ARIA_H__
16 
17 #include <sof/audio/component_ext.h>
18 #include <sof/audio/ipc-config.h>
19 #include <rtos/bit.h>
20 #include <sof/common.h>
21 #include <sof/trace/trace.h>
22 #include <ipc/stream.h>
23 #include <ipc4/module.h>
24 #include <ipc4/base-config.h>
25 #include <user/trace.h>
26 #include <stddef.h>
27 #include <stdint.h>
28 
29 /** \brief Aria max gain states */
30 #define ARIA_MAX_GAIN_STATES 10
31 
32 /** \brief Aria max att value */
33 #define ARIA_MAX_ATT 3
34 
35 /**
36  * \brief Aria gain processing function
37  */
38 void aria_algo_calc_gain(struct comp_dev *dev, size_t gain_idx,
39 			 int32_t *__restrict data, const size_t src_size);
40 
41 /**
42  * \brief Aria data processing function
43  */
44 void aria_algo_get_data(struct comp_dev *dev, int32_t *__restrict  data,
45 			size_t size);
46 
47 int aria_algo_buffer_data(struct comp_dev *dev, int32_t *__restrict data,
48 			  size_t size);
49 int aria_process_data(struct comp_dev *dev, int32_t *__restrict dst,
50 		      size_t dst_size, int32_t *__restrict src, size_t src_size);
51 
52 /**
53  * \brief Aria component private data.
54  */
55 struct aria_data {
56 	struct ipc4_base_module_cfg base;
57 
58 	/* channels count */
59 	size_t chan_cnt;
60 	/* sample groups to process count */
61 	size_t smpl_group_cnt;
62 	/* Size of chunk (1ms) in samples */
63 	size_t buff_size;
64 	/* Current gain state */
65 	size_t gain_state;
66 	/* current data position in circular buffer */
67 	size_t buff_pos;
68 	/* Attenuation parameter */
69 	size_t att;
70 	/* Gain states */
71 	int32_t gains[ARIA_MAX_GAIN_STATES];
72 	/* cyclic buffer for data */
73 	int32_t *data;
74 	/* buffer for data in */
75 	int32_t *buf_in;
76 	/* buffer for data out */
77 	int32_t *buf_out;
78 	/* internal buffer offset helps to keep algorithmic delay constant */
79 	size_t offset;
80 };
81 
82 #endif /* __SOF_AUDIO_ARIA_H__ */
83