Developer World
Spresense SDK Library v1.4.2-3df2e9d
audio_frontend_api.h
Go to the documentation of this file.
1 /****************************************************************************
2  * modules/include/audio/audio_frontend_api.h
3  *
4  * Copyright 2019 Sony Semiconductor Solutions Corporation
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17  * the names of its contributors may be used to endorse or promote
18  * products derived from this software without specific prior written
19  * permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
35 
36 #ifndef __MODULES_INCLUDE_AUDIO_AUDIO_FRONTEND_API_H
37 #define __MODULES_INCLUDE_AUDIO_AUDIO_FRONTEND_API_H
38 
53 /****************************************************************************
54  * Included Files
55  ****************************************************************************/
56 
57 #include <stdint.h>
58 #include <stdbool.h>
59 
63 
64 /****************************************************************************
65  * Pre-processor Definitions
66  ****************************************************************************/
67 
68 #define AS_FEATURE_FRONTEND_ENABLE
69 
75 #define LENGTH_INIT_MICFRONTEND 4
76 
79 #define LENGTH_INIT_PREPROCESS_DSP 4
80 
83 #define LENGTH_SET_PREPROCESS_DSP 4
84 
89 #define AS_PREPROCESS_FILE_PATH_LEN 22
90 
91 /****************************************************************************
92  * Public Types
93  ****************************************************************************/
94 
97 typedef enum
98 {
102 
106 
110 
114 
118 
122 
126 
130 
132 
133 typedef enum
134 {
135  AsMicFrontendDeviceMic = 0,
136 
137 } AsMicFrontendInputDevice;
138 
141 typedef enum
142 {
146 
150 
154 
155  AsMicFrontendPreProcInvalid = 0xff,
156 
158 
159 typedef enum
160 {
164 
168 
172 
174 
177 typedef struct
178 {
184  uint8_t input_device;
185 
187 
188 typedef bool (*MicFrontendCallback)(AsMicFrontendEvent evtype, uint32_t result, uint32_t sub_result);
189 
190 typedef struct
191 {
193 
194  MicFrontendCallback cb;
195 
197 
200 typedef struct
201 {
202  uint32_t reserve;
203 
205 
208 typedef void (*FrontendDoneCallback)(AsPcmDataParam param);
209 
211 {
213 
214  CMN_SimpleFifoHandle *simple_fifo_handler;
215 
216  struct __st_tunnel
217  {
218  uint8_t msgqid;
219  uint16_t msgtype;
220  } msg;
221 };
222 
223 typedef struct
224 {
228  uint8_t channel_number;
229 
233  uint8_t bit_length;
234 
239 
245  uint32_t out_fs;
246 
252  uint8_t preproc_type;
253 
258 
264  uint8_t data_path;
265 
272 
274 
277 typedef struct
278 {
279  uint32_t reserve;
280 
282 
285 typedef struct
286 {
287  uint32_t stop_mode;
288 
290 
293 typedef struct
294 {
297  uint8_t *packet_addr;
298 
301  uint32_t packet_size;
302 
304 
307 typedef struct
308 {
318  int16_t mic_gain[AS_MIC_CHANNEL_MAX];
319 
321 
324 typedef struct
325 {
328  uint8_t command_code;
329 
332  uint8_t reserved0;
333  uint8_t reserved1;
334  uint8_t reserved2;
335 
337 
340 typedef struct
341 {
345 
348  union
349  {
355 
361 
367 
373 
379 
385 
390  AsSetPreProcParam setpreproc_param;
391 
397  };
398 
400 
403 typedef struct
404 {
407  uint8_t micfrontend;
408 
411  uint8_t mng;
412 
415  uint8_t dsp;
416 
418 
421 typedef struct
422 {
426 
430 
434 
436 
437 typedef struct
438 {
441  uint8_t input;
442 
445  uint8_t output;
446 
449  uint8_t dsp;
450 
452 
455 typedef struct
456 {
460 
464 
466 
467 typedef struct
468 {
472 
476 
478 
479 /****************************************************************************
480  * Public Data
481  ****************************************************************************/
482 
483 /****************************************************************************
484  * Inline Functions
485  ****************************************************************************/
486 
487 /****************************************************************************
488  * Public Function Prototypes
489  ****************************************************************************/
490 
502  AudioAttentionCb attcb);
503 
505  AudioAttentionCb attcb);
506 
517 
527 bool AS_InitMicFrontend(FAR AsInitMicFrontendParam *initparam);
528 
538 bool AS_StartMicFrontend(FAR AsStartMicFrontendParam *startparam);
539 
549 bool AS_StopMicFrontend(FAR AsStopMicFrontendParam *stopparam);
550 
559 
567 bool AS_SetPreprocMicFrontend(FAR AsSetPreProcParam *param);
568 
576 bool AS_SetMicGainMicFrontend(FAR AsMicFrontendMicGainParam *micgain_param);
577 
586 
594 bool AS_DeleteMicFrontend(void);
595 
604 
605 #endif /* __MODULES_INCLUDE_AUDIO_AUDIO_FRONTEND_API_H */
606 
AsMicFrontendMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_frontend_api.h:471
AsInitPreProcParam initpreproc_param
[in] for InitPreProc (Object Interface==AS_InitPreProcFrontend)
Definition: audio_frontend_api.h:384
Definition: audio_common_defs.h:613
CXD5602 Audio Object Layer API.
MicFrontendCommandHeader header
[in] Command Header
Definition: audio_frontend_api.h:344
bool AS_DeleteMicFrontend(void)
Delete mic frontend.
uint8_t reserved0
[in] reserved
Definition: audio_frontend_api.h:332
uint16_t samples_per_frame
[in] Samples per a frame
Definition: audio_frontend_api.h:238
void(* FrontendDoneCallback)(AsPcmDataParam param)
Definition: audio_frontend_api.h:208
Definition: audio_frontend_api.h:293
uint32_t packet_size
[in] Command packet size
Definition: audio_frontend_api.h:301
uint8_t channel_number
[in] Select InitMicFrontend input channels
Definition: audio_frontend_api.h:228
Set PreProc.
Definition: audio_frontend_api.h:125
Activate.
Definition: audio_frontend_api.h:101
MemMgrLite::PoolId input
[in] Memory pool id of input data
Definition: audio_frontend_api.h:425
Definition: audio_frontend_api.h:177
AsMicFrontendMicGainParam mic_gain_param
[in] for SetMicGain (Object Interface==AS_SetMicGainFrontend)
Definition: audio_frontend_api.h:396
Definition: audio_frontend_api.h:307
Definition: audio_frontend_api.h:324
uint8_t mng
[in] Message queue id of audio_manager
Definition: audio_frontend_api.h:411
uint8_t output
[in] Memory pool id of PreProc
Definition: audio_frontend_api.h:445
Pre Process through.
Definition: audio_frontend_api.h:145
bool AS_DeactivateMicFrontend(FAR AsDeactivateMicFrontendParam *deactparam)
Deactivate mic frontend.
void(* AudioAttentionCb)(const ErrorAttentionParam *attparam)
Definition: audio_common_defs.h:721
PCM data is send by simple FIFO.
Definition: audio_frontend_api.h:171
bool AS_StartMicFrontend(FAR AsStartMicFrontendParam *startparam)
Start mic frontend.
bool AS_ActivateMicFrontend(FAR AsActivateMicFrontend *actparam)
Activate mic frontend.
bool AS_checkAvailabilityMicFrontend(void)
Check availability of MicFrontend.
AsDataDest dest
[in] Data destination, callback or message
Definition: audio_frontend_api.h:271
Set MicGain.
Definition: audio_frontend_api.h:129
Start.
Definition: audio_frontend_api.h:113
uint8_t data_path
[in] Select Data path from MicFrontend
Definition: audio_frontend_api.h:264
AsActivateMicFrontend act_param
[in] for ActivateFrontend (Object Interface==AS_ActivateFrontend)
Definition: audio_frontend_api.h:354
Definition: audio_frontend_api.h:223
uint8_t input_device
[in] Select Mic Frontend input device
Definition: audio_frontend_api.h:184
AsMicFrontendPoolId_old_t pool_id
[in] ID of memory pool for processing data
Definition: audio_frontend_api.h:463
PCM data is send by message.
Definition: audio_frontend_api.h:167
Pre Process user customed.
Definition: audio_frontend_api.h:153
CXD5602 Audio Common Definitions.
uint8_t input
[in] Memory pool id of input data
Definition: audio_frontend_api.h:441
Init PreProc.
Definition: audio_frontend_api.h:121
Pre Process Sampling Rate Conveter.
Definition: audio_frontend_api.h:149
Definition: audio_frontend_api.h:455
AsMicFrontendMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_frontend_api.h:459
Definition: audio_frontend_api.h:421
Definition: audio_frontend_api.h:403
AsMicFrontendDataPath
Definition: audio_frontend_api.h:159
FIFO handle which holds data required to manipulate FIFO.
Definition: CMN_SimpleFifo.h:78
AsDeactivateMicFrontendParam deact_param
[in] for DeactivateFrontend (Object Interface==AS_DeactivateFrontend)
Definition: audio_frontend_api.h:360
uint8_t preproc_type
[in] Select pre process enable
Definition: audio_frontend_api.h:252
Definition: MemMgrTypes.h:88
bool AS_SetPreprocMicFrontend(FAR AsSetPreProcParam *param)
Set pre process.
AsSetPreProcParam setpreproc_param
[in] for SetPreProc (Object Interface==AS_SetPreProcFrontend)
Definition: audio_frontend_api.h:390
bool AS_CreateMicFrontend(FAR AsCreateMicFrontendParam_t *param, AudioAttentionCb attcb)
Create mic frontend.
Definition: audio_frontend_api.h:285
MemMgrLite::PoolId dsp
[in] Memory pool id of dsp command data
Definition: audio_frontend_api.h:433
uint8_t bit_length
[in] Select InitMicFrontend input bit length
Definition: audio_frontend_api.h:233
bool AS_InitPreprocFrontend(FAR AsInitPreProcParam *param)
Init pre process.
uint8_t command_code
[in] Command code
Definition: audio_frontend_api.h:328
Definition: audio_frontend_api.h:277
#define AS_MIC_CHANNEL_MAX
Definition: audio_common_defs.h:84
uint8_t * packet_addr
[in] Command packet address
Definition: audio_frontend_api.h:297
CXD5602 Sipmle Fifo API.
Stop.
Definition: audio_frontend_api.h:117
PCM data is send by callback.
Definition: audio_frontend_api.h:163
AsMicFrontendPoolId_t pool_id
[in] ID of memory pool for processing data
Definition: audio_frontend_api.h:475
AsMicFrontendPreProcType
Definition: audio_frontend_api.h:141
Init.
Definition: audio_frontend_api.h:109
Definition: audio_frontend_api.h:437
bool AS_SetMicGainMicFrontend(FAR AsMicFrontendMicGainParam *micgain_param)
Set Mic gain.
Definition: audio_frontend_api.h:190
Definition: audio_frontend_api.h:216
uint32_t out_fs
[in] Output Fs
Definition: audio_frontend_api.h:245
bool AS_InitMicFrontend(FAR AsInitMicFrontendParam *initparam)
Init mic frontend.
uint8_t dsp
[in] Message queue id of DSP
Definition: audio_frontend_api.h:415
bool AS_StopMicFrontend(FAR AsStopMicFrontendParam *stopparam)
Stop mic frontend.
#define AS_PREPROCESS_FILE_PATH_LEN
Length of Recognizer dsp file name and path.
Definition: audio_frontend_api.h:89
AsMicFrontendEvent
Definition: audio_frontend_api.h:97
Definition: audio_frontend_api.h:340
AsStartMicFrontendParam start_param
[in] for StartFrontend (Object Interface==AS_StartMicFrontend)
Definition: audio_frontend_api.h:372
uint8_t micfrontend
[in] Message queue id of micfrontend
Definition: audio_frontend_api.h:407
Deactivate.
Definition: audio_frontend_api.h:105
AsInitMicFrontendParam init_param
[in] for InitFrontend (Object Interface==AS_InitMicFrontend)
Definition: audio_frontend_api.h:366
AsStopMicFrontendParam stop_param
[in] for StopFrontend (Object Interface==AS_StopMicFrontend)
Definition: audio_frontend_api.h:378
Definition: audio_frontend_api.h:467
Definition: audio_frontend_api.h:200
Definition: audio_frontend_api.h:210
MemMgrLite::PoolId output
[in] Memory pool id of PreProc
Definition: audio_frontend_api.h:429
uint8_t dsp
[in] Memory pool id of dsp command data
Definition: audio_frontend_api.h:449