Developer World
Spresense SDK Library v2.0.1-3834d32
audio_common_defs.h
Go to the documentation of this file.
1 /****************************************************************************
2  * modules/include/audio/audio_common_defs.h
3  *
4  * Copyright 2018 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_COMMON_DEFS_H
37 #define __MODULES_INCLUDE_AUDIO_AUDIO_COMMON_DEFS_H
38 
39 #include <arch/chip/audio.h>
40 
46 /* API Documents creater with Doxgen */
47 
57 /****************************************************************************
58  * Included Files
59  ****************************************************************************/
60 
62 
63 /****************************************************************************
64  * Pre-processor Definitions
65  ****************************************************************************/
66 
67 /* const for baseband */
71 #define AS_VOLUME_DAC -20
72 
73 /* TODO:Be removed in future */
74 
75 #define AS_AC_CODEC_VOL_DAC -20
76 
79 /* ---------------------------------*/
80 
86 #define AS_MIC_CHANNEL_MAX 8
87 
88 
91 #define AS_MICGAIN_HOLD 215
92 
98 #define AS_VOLUME_HOLD 255
99 
102 #define AS_VOLUME_MUTE -1025
103 
106 #define AS_BEEP_VOL_HOLD 255
107 
110 #define AS_BEEP_FREQ_HOLD 0
111 
114 #define AS_MICGAIN_MUTE -7855
115 
123 #define AS_CODECTYPE_MP3 0
124 
127 #define AS_CODECTYPE_WAV 1
128 
131 #define AS_CODECTYPE_AAC 2
132 
135 #define AS_CODECTYPE_OPUS 3
136 
139 #define AS_CODECTYPE_MEDIA 4
140 
143 #define AS_CODECTYPE_LPCM 5
144 
152 #define AS_BITLENGTH_16 16
153 
156 #define AS_BITLENGTH_24 24
157 
160 #define AS_BITLENGTH_32 32
161 
169 #define AS_CHANNEL_MONO 1
170 
173 #define AS_CHANNEL_STEREO 2
174 
177 #define AS_CHANNEL_4CH 4
178 
181 #define AS_CHANNEL_6CH 6
182 
185 #define AS_CHANNEL_8CH 8
186 
192 /* Auto */
193 
194 #define AS_SAMPLINGRATE_AUTO 0
195 
198 #define AS_SAMPLINGRATE_8000 8000
199 
202 #define AS_SAMPLINGRATE_11025 11025
203 
206 #define AS_SAMPLINGRATE_12000 12000
207 
210 #define AS_SAMPLINGRATE_16000 16000
211 
214 #define AS_SAMPLINGRATE_22050 22050
215 
218 #define AS_SAMPLINGRATE_24000 24000
219 
222 #define AS_SAMPLINGRATE_32000 32000
223 
226 #define AS_SAMPLINGRATE_44100 44100
227 
230 #define AS_SAMPLINGRATE_48000 48000
231 
234 #define AS_SAMPLINGRATE_64000 64000
235 
238 #define AS_SAMPLINGRATE_88200 88200
239 
242 #define AS_SAMPLINGRATE_96000 96000
243 
246 #define AS_SAMPLINGRATE_128000 128000
247 
250 #define AS_SAMPLINGRATE_176400 176400
251 
254 #define AS_SAMPLINGRATE_192000 192000
255 
263 #define AS_BITRATE_8000 8000
264 
267 #define AS_BITRATE_16000 16000
268 
271 #define AS_BITRATE_24000 24000
272 
275 #define AS_BITRATE_32000 32000
276 
279 #define AS_BITRATE_40000 40000
280 
283 #define AS_BITRATE_48000 48000
284 
287 #define AS_BITRATE_56000 56000
288 
291 #define AS_BITRATE_64000 64000
292 
295 #define AS_BITRATE_80000 80000
296 
299 #define AS_BITRATE_96000 96000
300 
303 #define AS_BITRATE_112000 112000
304 
307 #define AS_BITRATE_128000 128000
308 
311 #define AS_BITRATE_144000 144000
312 
315 #define AS_BITRATE_160000 160000
316 
319 #define AS_BITRATE_192000 192000
320 
323 #define AS_BITRATE_224000 224000
324 
327 #define AS_BITRATE_256000 256000
328 
331 #define AS_BITRATE_320000 320000
332 
335 #define AS_BITRATE_384000 384000
336 
339 #define AS_BITRATE_448000 448000
340 
343 #define AS_BITRATE_510000 510000
344 
352 typedef enum
353 {
357 
360 
364 
368 
372 
376 
380 
384 
388 
392 
396 
400 
404 
408 
412 
416 
420 
424 
425  AS_MODULE_ID_NUM,
426 } AsModuleId;
427 
437 #define AS_ATTENTION_CODE_INFORMATION 0x00
438 
445 #define AS_ATTENTION_CODE_WARNING 0x01
446 
453 #define AS_ATTENTION_CODE_ERROR 0x02
454 
460 #define AS_ATTENTION_CODE_FATAL 0x03
461 
473 #define AS_ATTENTION_SUB_CODE_DMA_UNDERFLOW 0x01
474 
481 #define AS_ATTENTION_SUB_CODE_DMA_OVERFLOW 0x02
482 
487 #define AS_ATTENTION_SUB_CODE_DMA_ERROR 0x03
488 
493 #define AS_ATTENTION_SUB_CODE_APU_QUEUE_FULL 0x04
494 
501 #define AS_ATTENTION_SUB_CODE_SIMPLE_FIFO_UNDERFLOW 0x05
502 
509 #define AS_ATTENTION_SUB_CODE_SIMPLE_FIFO_OVERFLOW 0x06
510 
515 #define AS_ATTENTION_SUB_CODE_ILLEGAL_REQUEST 0x07
516 
521 #define AS_ATTENTION_SUB_CODE_INTERNAL_STATE_ERROR 0x08
522 
527 #define AS_ATTENTION_SUB_CODE_UNEXPECTED_PARAM 0x09
528 
533 #define AS_ATTENTION_SUB_CODE_QUEUE_POP_ERROR 0x0A
534 
539 #define AS_ATTENTION_SUB_CODE_QUEUE_PUSH_ERROR 0x0B
540 
545 #define AS_ATTENTION_SUB_CODE_QUEUE_MISSING_ERROR 0x0C
546 
552 #define AS_ATTENTION_SUB_CODE_MEMHANDLE_ALLOC_ERROR 0x0D
553 
558 #define AS_ATTENTION_SUB_CODE_MEMHANDLE_FREE_ERROR 0x0E
559 
565 #define AS_ATTENTION_SUB_CODE_TASK_CREATE_ERROR 0x0F
566 
573 #define AS_ATTENTION_SUB_CODE_RESOURCE_ERROR 0x10
574 
579 #define AS_ATTENTION_SUB_CODE_DECODED_SIZE_ZERO 0x11
580 
586 #define AS_ATTENTION_SUB_CODE_DSP_LOAD_ERROR 0x12
587 
593 #define AS_ATTENTION_SUB_CODE_DSP_UNLOAD_ERROR 0x13
594 
599 #define AS_ATTENTION_SUB_CODE_DSP_EXEC_ERROR 0x14
600 
605 #define AS_ATTENTION_SUB_CODE_DSP_RESULT_ERROR 0x15
606 
612 #define AS_ATTENTION_SUB_CODE_DSP_ILLEGAL_REPLY 0x16
613 
618 #define AS_ATTENTION_SUB_CODE_DSP_UNLOAD_DONE 0x17
619 
624 #define AS_ATTENTION_SUB_CODE_DSP_VERSION_ERROR 0x18
625 
630 #define AS_ATTENTION_SUB_CODE_BASEBAND_ERROR 0x19
631 
637 #define AS_ATTENTION_SUB_CODE_STREAM_PARSER_ERROR 0x1A
638 
643 #define AS_ATTENTION_SUB_CODE_DSP_LOAD_DONE 0x1B
644 
649 #define AS_ATTENTION_SUB_CODE_RECSTART 0x1C
650 
655 #define AS_ATTENTION_SUB_CODE_RECSTOP 0x1D
656 
662 #define AS_ATTENTION_SUB_CODE_DSP_LOG_ALLOC_ERROR 0x1E
663 
668 #define AS_ATTENTION_SUB_CODE_DSP_ASSETION_FAIL 0x1F
669 
674 #define AS_ATTENTION_SUB_CODE_DSP_SEND_ERROR 0x20
675 
681 #define AS_ATTENTION_SUB_CODE_ALLOC_HEAP_MEMORY 0x21
682 
683 #define AS_ATTENTION_SUB_CODE_NUM AS_ATTENTION_SUB_CODE_ALLOC_HEAP_MEMORY
684 
689 #define AS_AUDIO_DSP_PATH_LEN 24
690 
691 /****************************************************************************
692  * Public Types
693  ****************************************************************************/
694 typedef void (*PcmProcDoneCallback)(int32_t identifier, bool is_end);
695 
698 typedef struct
699 {
702  int32_t identifier;
703 
706  PcmProcDoneCallback callback;
707 
711 
714  uint32_t sample;
715 
718  uint32_t size;
719 
722  bool is_end;
723 
726  bool is_valid;
727 
730  uint8_t bit_length;
731 
733 
734 typedef struct
735 {
739 
742  uint32_t size;
743 
745 
748 #define ATTENTION_FILE_NAME_LEN 32
749 
750 typedef struct
751 {
754  uint32_t reserved1;
755 
758  uint8_t error_code;
759 
762  uint8_t cpu_id;
763 
766  uint8_t sub_module_id;
767 
770  uint8_t module_id;
771 
775 
778  uint32_t reserved2;
779 
782  uint16_t line_number;
783 
786  uint8_t task_id;
787 
790  uint8_t reserved3;
791 
794  union
795  {
796  uint32_t align_dummy;
797  char error_filename[ATTENTION_FILE_NAME_LEN];
798  };
799 
801 
806 typedef void (*AudioAttentionCb)(const ErrorAttentionParam *attparam);
807 
808 #ifndef ATTENTION_USE_FILENAME_LINE
809 typedef void (*obs_AudioAttentionCb)(uint8_t module_id,
810  uint8_t error_code,
811  uint8_t sub_code);
812 #else
813 typedef void (*obs_AudioAttentionCb)(uint8_t module_id,
814  uint8_t error_code,
815  uint8_t sub_code,
816  FAR const char *file_name,
817  uint32_t line);
818 #endif
819 
820 #endif /* __MODULES_INCLUDE_AUDIO_AUDIO_COMMON_DEFS_H */
821 
Filter Component ID.
Definition: audio_common_defs.h:407
Definition: audio_common_defs.h:698
uint8_t bit_length
[in] Data bit length
Definition: audio_common_defs.h:730
uint8_t reserved3
[out] reserved
Definition: audio_common_defs.h:790
int32_t identifier
[in] Data identifier, use anyway
Definition: audio_common_defs.h:702
uint32_t error_att_sub_code
[out] Detailed Error Infomation, T.B.D.
Definition: audio_common_defs.h:774
Input Data Manager Object ID.
Definition: audio_common_defs.h:367
uint8_t task_id
[out] Task ID (internal use only)
Definition: audio_common_defs.h:786
Audio Manager Module ID.
Definition: audio_common_defs.h:356
uint32_t sample
[in] Sample number of PCM data
Definition: audio_common_defs.h:714
Media Recorder Object ID.
Definition: audio_common_defs.h:371
uint8_t error_code
[out] Error Infomation, T.B.D.
Definition: audio_common_defs.h:758
MemMgrLite::MemHandle mh
[in] Memory handle for recognition result information.
Definition: audio_common_defs.h:738
void(* AudioAttentionCb)(const ErrorAttentionParam *attparam)
Definition: audio_common_defs.h:806
Renderer Component ID.
Definition: audio_common_defs.h:415
Memory Handler API.
Capture Component ID.
Definition: audio_common_defs.h:395
AsModuleId
Definition: audio_common_defs.h:352
Output Mix Object ID.
Definition: audio_common_defs.h:375
uint8_t module_id
[out] Error module infomation, T.B.D.
Definition: audio_common_defs.h:770
bool is_end
[in] True: Last data of current session.
Definition: audio_common_defs.h:722
uint32_t reserved2
[out] reserved
Definition: audio_common_defs.h:778
Recognition Component ID.
Definition: audio_common_defs.h:411
Memory Handler Class for "Memory Manager Lite". This is only wrapper class for convert project-specif...
Definition: MemManager.h:107
#define ATTENTION_FILE_NAME_LEN
Definition: audio_common_defs.h:748
Audio Baseband Driver Module ID.
Definition: audio_common_defs.h:359
Sound Effect Object ID.
Definition: audio_common_defs.h:387
bool is_valid
[in] True: Valid PCM frame.
Definition: audio_common_defs.h:726
uint32_t reserved1
[out] reserved
Definition: audio_common_defs.h:754
Recognition Object ID.
Definition: audio_common_defs.h:383
Synthesizer Object ID.
Definition: audio_common_defs.h:391
Player Object ID.
Definition: audio_common_defs.h:379
MemMgrLite::MemHandle mh
[in] Memory handle for output PCM data
Definition: audio_common_defs.h:710
Decoder Component ID.
Definition: audio_common_defs.h:399
uint8_t cpu_id
[out] CPU ID (internal use only)
Definition: audio_common_defs.h:762
Definition: audio_common_defs.h:734
Encoder Component ID.
Definition: audio_common_defs.h:403
uint8_t sub_module_id
[out] for debug purpose
Definition: audio_common_defs.h:766
uint16_t line_number
[out] Line No (internal use only)
Definition: audio_common_defs.h:782
uint32_t size
[in] Size recognition result information.
Definition: audio_common_defs.h:742
Definition: audio_common_defs.h:750
Oscillator Component ID.
Definition: audio_common_defs.h:423
FrontEnd Object ID.
Definition: audio_common_defs.h:363
uint32_t size
[in] Byte size of input data
Definition: audio_common_defs.h:718
Postfilter Component ID.
Definition: audio_common_defs.h:419