csi_audio_common.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (C) 2021 Alibaba Group Holding Limited
  3. * Author: fuqian.zxr <fuqian.zxr@alibaba-inc.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef __CSI_AUDIO_COMMON_H__
  10. #define __CSI_AUDIO_COMMON_H__
  11. #include <unistd.h>
  12. #include <stdint.h>
  13. #include <stdbool.h>
  14. #include "csi_common.h"
  15. #define MAX_AUDIO_FILE_PATH_LEN 256
  16. #define VQE_EQ_BAND_NUM 10
  17. typedef enum csi_audio_sample_rate {
  18. AUDIO_SAMPLE_RATE_8000 = 8000, /*8K samplerate*/
  19. AUDIO_SAMPLE_RATE_12000 = 12000, /*12K samplerate*/
  20. AUDIO_SAMPLE_RATE_11025 = 11025, /*11.025K samplerate*/
  21. AUDIO_SAMPLE_RATE_16000 = 16000, /*16K samplerate*/
  22. AUDIO_SAMPLE_RATE_22050 = 22050, /*22.05k samplerate*/
  23. AUDIO_SAMPLE_RATE_24000 = 24000, /*24K samplerate*/
  24. AUDIO_SAMPLE_RATE_32000 = 32000, /*32K samplerate*/
  25. AUDIO_SAMPLE_RATE_44100 = 44100, /*44.1K samplerate*/
  26. AUDIO_SAMPLE_RATE_48000 = 48000, /*48K samplerate*/
  27. AUDIO_SAMPLE_RATE_64000 = 64000, /*64K samplerate*/
  28. AUDIO_SAMPLE_RATE_96000 = 96000, /*96K samplerate*/
  29. AUDIO_SAMPLE_RATE_BUTT,
  30. }csi_audio_sample_rate_e;
  31. typedef enum csi_audio_bit_width {
  32. AUDIO_BIT_WIDTH_8 = 0, /*8bit width*/
  33. AUDIO_BIT_WIDTH_16 = 1, /*16bit width*/
  34. AUDIO_BIT_WIDTH_24 = 2, /*24bit width*/
  35. AUDIO_BIT_WIDTH_BUTT,
  36. }csi_audio_bit_width_e;
  37. typedef enum csi_audio_mode {
  38. AIO_MODE_I2S_MASTER = 0, /* AIO I2S master mode */
  39. AIO_MODE_I2S_SLAVE, /* AIO I2S slave mode */
  40. AIO_MODE_PCM_SLAVE_STD, /* AIO PCM slave standard mode */
  41. AIO_MODE_PCM_SLAVE_NSTD, /* AIO PCM slave non-standard mode */
  42. AIO_MODE_PCM_MASTER_STD, /* AIO PCM master standard mode */
  43. AIO_MODE_PCM_MASTER_NSTD, /* AIO PCM master non-standard mode */
  44. AIO_MODE_BUTT,
  45. }csi_audio_mode_e;
  46. typedef enum csi_audio_sound_mode {
  47. AUDIO_SOUND_MODE_MONO = 0, /*mono*/
  48. AUDIO_SOUND_MODE_STEREO = 1, /*stereo*/
  49. AUDIO_SOUND_MODE_BUTT
  50. }csi_audio_sound_mode_e;
  51. typedef enum csi_auido_i2stype {
  52. AIO_I2STYPE_INNERCODEC = 0, /*AIO I2S connect inner audio CODEC*/
  53. AIO_I2STYPE_INNERHDMI, /*AIO I2S connect inner HDMI*/
  54. AIO_I2STYPE_EXTERN, /*AIO I2S connect extern hardware*/
  55. }csi_auido_i2stype_e;
  56. typedef struct csi_aio_attr {
  57. csi_audio_sample_rate_e samplerate; /*sample rate*/
  58. csi_audio_bit_width_e bitwidth; /*bitwidth*/
  59. csi_audio_mode_e workmode; /*master or slave mode*/
  60. csi_audio_sound_mode_e soundmode; /*mono or steror*/
  61. uint32_t exflag;
  62. uint32_t frmnum;
  63. uint32_t pt_num_per_frm;
  64. uint32_t chncnt;
  65. csi_auido_i2stype_e i2stype;
  66. }csi_aio_attr_s;
  67. typedef struct csi_audio_frame {
  68. csi_audio_bit_width_e bitwidth;
  69. csi_audio_sound_mode_e soundmode;
  70. void *viraddr[2];
  71. uint32_t phyaddr[2];
  72. uint64_t timestamp; /*audio frame timestamp*/
  73. uint32_t seq; /*audio frame seq*/
  74. uint32_t len; /*data length per channel in frame*/
  75. uint32_t poolid[2];
  76. }csi_audio_frame_s;
  77. typedef enum csi_audio_track_mode {
  78. AUDIO_TRACK_NORMAL = 0,
  79. AUDIO_TRACK_BOTH_LEFT = 1,
  80. AUDIO_TRACK_BOTH_RIGHT = 2,
  81. AUDIO_TRACK_EXCHANGE = 3,
  82. AUDIO_TRACK_MIX = 4,
  83. AUDIO_TRACK_LEFT_MUTE = 5,
  84. AUDIO_TRACK_RIGHT_MUTE = 6,
  85. AUDIO_TRACK_BOTH_MUTE = 7,
  86. AUDIO_TRACK_BUTT,
  87. }csi_audio_track_mode_e;
  88. typedef struct csi_audio_save_file_info {
  89. bool cfg;
  90. char filepath[MAX_AUDIO_FILE_PATH_LEN];
  91. char filename[MAX_AUDIO_FILE_PATH_LEN];
  92. uint32_t filesize;
  93. }csi_audio_save_file_info_s;
  94. typedef struct csi_audio_file_status {
  95. bool saving;
  96. }csi_audio_file_status_s;
  97. typedef enum csi_vqe_workstate {
  98. VQE_WORKSTATE_COMMON = 0,
  99. VQE_WORKSTATE_MUSIC = 1,
  100. VQE_WORKSTATE_NOISY = 2
  101. }csi_vqe_workstate_e;
  102. typedef enum csi_audio_hpf_freq {
  103. AUDIO_HPF_FREQ_80 = 80, /*80HZ*/
  104. AUDIO_HPF_FREQ_120 = 120, /*120Hz*/
  105. AUDIO_HPF_FREQ_150 = 150, /*150Hz*/
  106. AUDIO_HPF_FREQ_BUTT,
  107. }csi_audio_hpf_freq_e;
  108. typedef struct csi_audio_hpf_config {
  109. bool usrmode;
  110. csi_audio_hpf_freq_e hpffreq;
  111. }csi_audio_hpf_config_s;
  112. typedef struct csi_audio_anr_config {
  113. bool usrmode;
  114. int16_t nrintensity;
  115. int16_t noisedbthr;
  116. int8_t sp_pro_switch;
  117. int32_t reserved;
  118. }csi_audio_anr_config_s;
  119. typedef struct csi_audio_agc_config {
  120. bool usrmode;
  121. int8_t target_level;
  122. int8_t noise_floor;
  123. int8_t maxgain;
  124. int8_t adjustspeed;
  125. int8_t improvesnr;
  126. int8_t usehighpassfilt;
  127. int8_t outputmode;
  128. int16_t noisesupswitch;
  129. int32_t reserved;
  130. }csi_audio_agc_config_s;
  131. typedef struct csi_audio_eq_config {
  132. int8_t gaindb[VQE_EQ_BAND_NUM];
  133. int32_t reserved;
  134. }csi_audio_eq_config_s;
  135. typedef enum {
  136. PT_PCMU = 0,
  137. PT_1016 = 1,
  138. PT_BUTT
  139. }PAYLOAD_TYPE_E;
  140. typedef struct csi_audio_stream {
  141. uint8_t *stream; /*the virtual address of stream*/
  142. uint32_t phyaddr; /*the physics address of stream*/
  143. uint32_t len; /*stream length,by bytes*/
  144. uint64_t timestamp; /*frame time stamp*/
  145. uint32_t seq; /*frame seq,if stream is not a valid frame 0*/
  146. }csi_audio_stream_s;
  147. #endif