|
| 1 | +/* SPDX-License-Identifier: BSD-3-Clause |
| 2 | + * |
| 3 | + * Copyright(c) 2024 Intelligo Technology Inc. All rights reserved. |
| 4 | + * |
| 5 | + * Author: Fu-Yun TSUO <[email protected]> |
| 6 | + */ |
| 7 | + |
| 8 | +/******************************************************************************* |
| 9 | + * [2017] - [2024] Copyright (c) Intelligo Technology Inc. |
| 10 | + * |
| 11 | + * This unpublished material is proprietary to Intelligo Technology Inc. |
| 12 | + * All rights reserved. The methods and techniques described herein are |
| 13 | + * considered trade secrets and/or confidential. Reproduction or |
| 14 | + * distribution, in whole or in part, is forbidden except by express written |
| 15 | + * permission of Intelligo Technology Inc. |
| 16 | + * |
| 17 | + *******************************************************************************/ |
| 18 | + |
| 19 | +#ifndef _IGO_LIB_H_ |
| 20 | +#define _IGO_LIB_H_ |
| 21 | + |
| 22 | +#include <stdint.h> |
| 23 | + |
| 24 | +enum IgoRet { |
| 25 | + IGO_RET_OK = 0, |
| 26 | + IGO_RET_ERR, |
| 27 | + IGO_RET_NO_SERVICE, |
| 28 | + IGO_RET_INVL_ARG, |
| 29 | + IGO_RET_NO_MEMORY, |
| 30 | + IGO_RET_NOT_SUPPORT, |
| 31 | + IGO_RET_ALGO_NAME_NOT_FOUND, |
| 32 | + IGO_RET_CH_NUM_ERR, |
| 33 | + IGO_RET_SAMPLING_RATE_NOT_SUPPORT, |
| 34 | + IGO_RET_IN_DATA_ERR, |
| 35 | + IGO_RET_REF_DATA_ERR, |
| 36 | + IGO_RET_OUT_DATA_ERR, |
| 37 | + IGO_RET_PARAM_NOT_FOUND, |
| 38 | + IGO_RET_PARAM_READ_ONLY, |
| 39 | + IGO_RET_PARAM_WRITE_ONLY, |
| 40 | + IGO_RET_PARAM_INVALID_VAL, |
| 41 | + IGO_RET_LAST |
| 42 | +}; |
| 43 | + |
| 44 | +enum IgoDataWidth { |
| 45 | + IGO_DATA_INT16 = 0, |
| 46 | + IGO_DATA_INT32, |
| 47 | + IGO_DATA_FLOAT32, |
| 48 | + IGO_DATA_LAST |
| 49 | +}; |
| 50 | + |
| 51 | +/** |
| 52 | + * @brief IgoLibInfo is used to keep information for iGo library. |
| 53 | + * |
| 54 | + */ |
| 55 | +struct IgoLibInfo { |
| 56 | + const char* algo_name; /* Algorithm name */ |
| 57 | + uint32_t source_id; /* Library source ID */ |
| 58 | + uint32_t date_code; /* BCD format. e.g., 0x20220527 */ |
| 59 | + uint32_t major_version; /* Major version */ |
| 60 | + uint32_t minor_version; /* Minor version */ |
| 61 | + uint32_t build_version; /* Build version */ |
| 62 | + uint32_t ext_version; /* Extension version */ |
| 63 | + uint32_t git_commit_id; /* Git commit ID */ |
| 64 | + uint8_t max_in_ch_num; /* Maximal input channel nubmer */ |
| 65 | + uint8_t max_ref_ch_num; /* Maximal reference channel nubmer */ |
| 66 | + uint8_t max_out_ch_num; /* Maximal output channel nubmer */ |
| 67 | +}; |
| 68 | + |
| 69 | +/** |
| 70 | + * @brief IgoStreamData is used to keep audio data for iGo library. |
| 71 | + * |
| 72 | + */ |
| 73 | +struct IgoStreamData { |
| 74 | + void* data; /* Data array */ |
| 75 | + enum IgoDataWidth data_width; /* Specify audio data bit width */ |
| 76 | + uint16_t sample_num; /* Sample number in this data bulk */ |
| 77 | + uint16_t sampling_rate; /* Sampling rate for the data stream */ |
| 78 | +}; |
| 79 | + |
| 80 | +/** |
| 81 | + * @brief IgoLibConfig is used to keep lib configuration for lib instance |
| 82 | + * initialization. |
| 83 | + * |
| 84 | + */ |
| 85 | +struct IgoLibConfig { |
| 86 | + const void* private_data; /* Point to private data */ |
| 87 | + void* public_data; /* Point to public data */ |
| 88 | + uint8_t in_ch_num; /* Input channel number in use*/ |
| 89 | + uint8_t ref_ch_num; /* Reference channel number in use */ |
| 90 | + uint8_t out_ch_num; /* Output channel number in use*/ |
| 91 | +}; |
| 92 | + |
| 93 | +#ifdef __cplusplus |
| 94 | +extern "C" { |
| 95 | +#endif |
| 96 | + |
| 97 | +/** |
| 98 | + * @brief IgoLibGetInfo() - Retrieve the lib information. |
| 99 | + * @param[out] info Lib information. |
| 100 | + * |
| 101 | + * This API is used to get library detail information. |
| 102 | + * |
| 103 | + * @return iGo defined return value. |
| 104 | + */ |
| 105 | +enum IgoRet IgoLibGetInfo(struct IgoLibInfo* info); |
| 106 | + |
| 107 | +/** |
| 108 | + * @brief IgoLibNew() - Allocate an iGo lib instance. |
| 109 | + * @param[in] config Lib configuration. |
| 110 | + * @param[in] in input audio stream. |
| 111 | + * @param[in] ref reference audio stream. |
| 112 | + * @param[out] out output audio stream. |
| 113 | + * |
| 114 | + * This API is used to allocate an iGo lib instance |
| 115 | + * |
| 116 | + * @return iGo defined return value. |
| 117 | + */ |
| 118 | +enum IgoRet IgoLibNew(struct IgoLibConfig* config, |
| 119 | + struct IgoStreamData* in, |
| 120 | + struct IgoStreamData* ref, |
| 121 | + struct IgoStreamData* out); |
| 122 | + |
| 123 | +/** |
| 124 | + * @brief IgoLibSendBufferAddr() - Send address of data buffer to lib |
| 125 | + * @param[in] config Lib configuration. |
| 126 | + * @param[in] in input audio stream. |
| 127 | + * @param[in] ref reference audio stream. |
| 128 | + * @param[out] out output audio stream. |
| 129 | + * |
| 130 | + * This API is used to send buffer address to iGo lib instance. |
| 131 | + * |
| 132 | + * @return iGo defined return value. |
| 133 | + */ |
| 134 | +enum IgoRet IgoLibUpdateStreamData(struct IgoLibConfig* config, |
| 135 | + struct IgoStreamData* in, |
| 136 | + struct IgoStreamData* ref, |
| 137 | + struct IgoStreamData* out); |
| 138 | + |
| 139 | +/** |
| 140 | + * @brief IgoLibDelete() - Delete an iGo lib instance. |
| 141 | + * @param[in] config Lib configuration. |
| 142 | + * |
| 143 | + * This API is used to delete an iGo lib instance |
| 144 | + * |
| 145 | + * @return iGo defined return value. |
| 146 | + */ |
| 147 | +enum IgoRet IgoLibDelete(struct IgoLibConfig* config); |
| 148 | + |
| 149 | +/** |
| 150 | + * @brief IgoLibProcess() - Process audio stream. |
| 151 | + * @param[in] in input audio stream. |
| 152 | + * @param[in] ref reference audio stream. |
| 153 | + * @param[out] out output audio stream. |
| 154 | + * |
| 155 | + * This API is used to process audio stream. The default audio sample is 16bit. |
| 156 | + * The sampling rate and sample number should be specified in IgoStreamData |
| 157 | + * structure. If the channel number > 1 for IgoStreamData, the data should be |
| 158 | + * interleaved sample by sample. |
| 159 | + * |
| 160 | + * Note: IgoLibProcess supports 16k/48k 16bit data only by default. |
| 161 | + * If other data format or sampling rate is required, please |
| 162 | + * ask intelliGo for support. |
| 163 | + * |
| 164 | + * @return iGo defined return value. |
| 165 | + */ |
| 166 | +enum IgoRet IgoLibProcess(struct IgoLibConfig* config, |
| 167 | + struct IgoStreamData* in, |
| 168 | + struct IgoStreamData* ref, |
| 169 | + struct IgoStreamData* out); |
| 170 | + |
| 171 | +#ifdef __cplusplus |
| 172 | +} |
| 173 | +#endif |
| 174 | + |
| 175 | +#endif |
0 commit comments