dsp_hal_defs.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. /*
  2. * dsp_hal_defs.h
  3. *
  4. * Created on: 2019年5月23日
  5. * Author: wuyufan
  6. */
  7. #ifndef _DSP_HAL_DEFS_H_
  8. #define _DSP_HAL_DEFS_H_
  9. #include <stdint.h>
  10. #include <drivers/dsp.h>
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #define RINGBUF_TYPE uint32_t
  15. /*****************************************************************
  16. * DSP compilation time options. You can change these here by *
  17. * uncommenting the lines, or on the compiler command line. *
  18. *****************************************************************/
  19. /* Enable DSP music effect*/
  20. //#define DSP_SUPPORT_MUSIC_EFFECT
  21. /* Enable DSP voice effect */
  22. #define DSP_SUPPORT_VOICE_EFFECT
  23. /* Enable DSP ASRC effect */
  24. //#define DSP_SUPPORT_ASR_EFFECT
  25. /* Enable DSP decoder support resample*/
  26. //#define DSP_SUPPORT_DECODER_RESAMPLE
  27. //Enable DSP print
  28. #define DSP_SUPPORT_DEBUG_PRINT
  29. /* config DSP mix multi buffer num */
  30. #define DSP_SUPPORT_MULTI_BUFFER_NUM (2)
  31. /* config DSP AEC refs buf num */
  32. #define DSP_SUPPORT_AEC_REFBUF_NUM (1)
  33. #define DSP_AEC_REF_DELAY (1)
  34. #ifdef DSP_SUPPORT_MUSIC_EFFECT
  35. /* Enable DSP support player */
  36. #define DSP_SUPPORT_PLAYER
  37. /* Enable DSP support decoder */
  38. #define DSP_SUPPORT_DECODER
  39. /* Enable DSP decoder support DAE effect */
  40. #define DSP_SUPPORT_DECODER_DAE
  41. /* Enable DSP support sbc decoder */
  42. //#define DSP_SUPPORT_SBC_DECODER
  43. /* Enable DSP support aac decoder */
  44. #define DSP_SUPPORT_AAC_DECODER
  45. /* Enable DSP support output subwoofer */
  46. #define DSP_SUPPORT_OUTPUT_SUBWOOFER
  47. #endif
  48. #ifdef DSP_SUPPORT_VOICE_EFFECT
  49. /* Enable DSP support player */
  50. #define DSP_SUPPORT_PLAYER
  51. /* Enable DSP support recorder */
  52. #define DSP_SUPPORT_RECODER
  53. /* Enable DSP support decoder*/
  54. #define DSP_SUPPORT_DECODER
  55. /* Enable DSP support encoder */
  56. #define DSP_SUPPORT_ENCODER
  57. /* Enable DSP support AGC*/
  58. #define DSP_SUPPORT_AGC
  59. /* Enable DSP support PEQ*/
  60. #define DSP_SUPPORT_PEQ
  61. /* Enable DSP support decoder AGC */
  62. #define DSP_SUPPORT_DECODER_AGC
  63. /* Enable DSP support decoder PEQ */
  64. #define DSP_SUPPORT_DECODER_PEQ
  65. /* Enable DSP support encoder AGC */
  66. #define DSP_SUPPORT_ENCODER_AGC
  67. /* Enable DSP support encoder PEQ */
  68. #define DSP_SUPPORT_ENCODER_PEQ
  69. /* Enable DSP support msbc decoder */
  70. #define DSP_SUPPORT_MSBC_DECODER
  71. /* Enable DSP support msbc encoder */
  72. #define DSP_SUPPORT_MSBC_ENCODER
  73. /* Enable DSP support cvsd decoder */
  74. //#define DSP_SUPPORT_CVSD_DECODER
  75. /* Enable DSP support cvsd encoder */
  76. //#define DSP_SUPPORT_CVSD_ENCODER
  77. /* Enable DSP encoder support AEC */
  78. #define DSP_SUPPORT_ENCODER_AEC
  79. /* Enable DSP AEC SYNC with encoder */
  80. //#define DSP_SUPPORT_PLAYER_AEC_SYNC
  81. /* Enable DSP hardware AEC SYNC */
  82. #define DSP_SUPPORT_HARDWARE_AEC_SYNC
  83. /* Enable DSP encoder support CNG */
  84. #define DSP_SUPPORT_ENCODER_CNG
  85. #endif
  86. #if !defined(DSP_SUPPORT_MUSIC_EFFECT) && !defined(DSP_SUPPORT_VOICE_EFFECT)
  87. /* Enable DSP support recorder */
  88. #define DSP_SUPPORT_RECODER
  89. /* Enable DSP support encoder */
  90. #define DSP_SUPPORT_ENCODER
  91. /* Enable DSP support aac decoder */
  92. #define DSP_SUPPORT_OPUS_ENCODER
  93. #endif
  94. #ifdef DSP_SUPPORT_DEBUG_PRINT
  95. #define DSP_PUTS(a) dsp_puts(a)
  96. #define DSP_PRINTHEX(a) dsp_printhex(a)
  97. #else
  98. #define DSP_PUTS(a)
  99. #define DSP_PRINTHEX(a)
  100. #endif
  101. /* session ids */
  102. enum {
  103. DSP_SESSION_DEFAULT = 0,
  104. DSP_SESSION_MEDIA,
  105. DSP_NUM_SESSIONS,
  106. };
  107. /* session function ids */
  108. enum {
  109. /* basic functions */
  110. DSP_FUNCTION_DECODER = 0,
  111. DSP_FUNCTION_ENCODER,
  112. /* complex functions */
  113. DSP_FUNCTION_PLAYER,
  114. DSP_FUNCTION_RECORDER,
  115. DSP_FUNCTION_PREPROCESS,
  116. DSP_FUNCTION_POSTPROCESS,
  117. DSP_NUM_FUNCTIONS,
  118. };
  119. #define DSP_FUNC_BIT(func) BIT(func)
  120. #define DSP_FUNC_ALL BIT_MASK(DSP_NUM_FUNCTIONS)
  121. #if defined(DSP_SUPPORT_CVSD_DECODER) || defined(DSP_SUPPORT_CVSD_ENCODER)
  122. #define PCM_FRAMESZ (128)
  123. #else
  124. #define PCM_FRAMESZ (256)
  125. #endif
  126. /* session command ids */
  127. enum {
  128. /* session global commands */
  129. DSP_CMD_USER_DEFINED = 32,
  130. DSP_MIN_SESSION_CMD = DSP_CMD_USER_DEFINED,
  131. /* initialize static params before first run */
  132. DSP_CMD_SESSION_INIT = DSP_MIN_SESSION_CMD,
  133. /* begin session running (with dynamic params) */
  134. DSP_CMD_SESSION_BEGIN,
  135. /* end session running */
  136. DSP_CMD_SESSION_END,
  137. /* user-defined session command started from */
  138. DSP_CMD_SESSION_USER_DEFINED,
  139. /* configure the session working mode, it is required when the same library has two or more working modes,
  140. * such as a dsp library for gaming headphone has two working mode : dongle & headphone.
  141. */
  142. DSP_CMD_SESSION_WORKING_MODE,
  143. DSP_MAX_SESSION_CMD = DSP_MIN_SESSION_CMD + 0xFF,
  144. /* session function commands, function id is required */
  145. DSP_MIN_FUNCTION_CMD = DSP_MAX_SESSION_CMD + 0x1,
  146. /* configure function 288 */
  147. DSP_CMD_FUNCTION_CONFIG = DSP_MIN_FUNCTION_CMD,
  148. /* enable function */
  149. DSP_CMD_FUNCTION_ENABLE,
  150. /* disable function */
  151. DSP_CMD_FUNCTION_DISABLE,
  152. /* debug function */
  153. DSP_CMD_FUNCTION_DEBUG,
  154. /* pause function, like function_disable, but need not finalize function */
  155. DSP_CMD_FUNCTION_PAUSE,
  156. /* debug function, like function_enable, but need not initialize function */
  157. DSP_CMD_FUNCTION_RESUME,
  158. /* user-defined function command started from */
  159. DSP_CMD_FUNCTION_USER_DEFINED,
  160. DSP_MAX_FUNCTION_CMD = DSP_MIN_FUNCTION_CMD + 0xFF,
  161. };
  162. /* session function configuration ids for complex functions */
  163. enum {
  164. /* configure the default parameter set, for basic functions */
  165. DSP_CONFIG_DEFAULT = 0,
  166. /* configure the decoder parameter set, struct decoder_dspfunc_params */
  167. DSP_CONFIG_DECODER,
  168. /* configure the encoder parameter set, struct encoder_dspfunc_params */
  169. DSP_CONFIG_ENCODER,
  170. /* configure the encoder parameter set, struct dae_dspfunc_params */
  171. DSP_CONFIG_DAE,
  172. /* configure the aec reference parameter set, struct aec_dspfunc_ref_params */
  173. DSP_CONFIG_AEC_REF,
  174. /* configure the aec parameter set, struct aec_dspfunc_params */
  175. DSP_CONFIG_AEC,
  176. /* configure the playback mix parameter set, struct mix_dspfunc_params */
  177. DSP_CONFIG_MIX,
  178. /* configure the playback output parameter set, struct output_dspfunc_params */
  179. DSP_CONFIG_OUTPUT,
  180. /* configure the decoder extra parameter set, struct decoder_dspfunc_ext_params */
  181. DSP_CONFIG_DECODER_EXT,
  182. /* configure the postprocess energy set, struct energy_dspfunc_params */
  183. DSP_CONFIG_ENERGY,
  184. /* configure the postprocess misc set, such as auto mute, struct misc_dspfunc_parsms */
  185. DSP_CONFIG_MSIC,
  186. /* configure the postprocess type set, uint32_t music(0, default) or voice(1) */
  187. DSP_CONFIG_TYPE,
  188. /* configure the audio out channel parameter set, struct dspfunc_audio_out_params */
  189. DSP_CONFIG_AUDIO,
  190. /* configure dsp sleep parameter set, global, struct dspfunc_sleep_params */
  191. DSP_CONFIG_DSP_SLEEP,
  192. /* configure the player suspend */
  193. DSP_CONFIG_PLAYER_SUSPEND,
  194. /* configure the player resume */
  195. DSP_CONFIG_PLAYER_RESUME,
  196. /* configure the recorder suspend */
  197. DSP_CONFIG_RECORDER_SUSPEND,
  198. /* configure the recorder resume */
  199. DSP_CONFIG_RECORDER_RESUME,
  200. /* configure dsp play on time parameter set, global, struct dspfunc_play_ontime_params */
  201. DSP_CONFIG_PLAY_ONTIME,
  202. /* configure decoder output channel, asdec_chn_t */
  203. DSP_CONFIG_DECODE_CHANNEL,
  204. /* configure mixer stream */
  205. DSP_CONFIG_STREAM_END,
  206. /* configure music plc parameter set, struct decoder_dspfunc_ext_params_mplc */
  207. DSP_CONFIG_DECODER_MPLC,
  208. /* configure drop or insert data set, struct decoder_dspfunc_data_adjust */
  209. DSP_CONFIG_DATA_ADJUST,
  210. /* configure the nav decoder parameter set, struct decoder_dspfunc_nav_params */
  211. DSP_CONFIG_DECODER_NAV,
  212. /* configure the nav encoder parameter set, struct encoder_dspfunc_nav_params */
  213. DSP_CONFIG_ENCODER_NAV,
  214. /* configure xfer report parameter set, global, struct dspfunc_xfer_report_params */
  215. DSP_CONFIG_XFER_REPORT,
  216. /* notify the decoder that seek is happened */
  217. DSP_CONFIG_DECODER_ON_SEEK,
  218. /* configure the encoder ext parameter set, struct encoder_dspfunc_ext_params */
  219. DSP_CONFIG_ENCODER_EXT,
  220. };
  221. /* session error state */
  222. enum {
  223. /* 1 ~ 31 dev error state >32 session error*/
  224. DSP_BAD_STREAM = 32,
  225. DSP_DAC_FULL_EMPTY = 33,
  226. };
  227. /* codec format definition */
  228. enum {
  229. DSP_CODEC_FORMAT_MP3 = 1, /* MP3_TYPE */
  230. DSP_CODEC_FORMAT_WMA = 2, /* WMA_TYPE */
  231. DSP_CODEC_FORMAT_WAV = 3, /* WAV_TYPE */
  232. DSP_CODEC_FORMAT_FLAC = 4, /* FLA_TYPE */
  233. DSP_CODEC_FORMAT_APE = 5, /* APE_TYPE */
  234. DSP_CODEC_FORMAT_AAC = 6, /* AAC_TYPE */
  235. DSP_CODEC_FORMAT_OGG = 7, /* OGGC_TYPE */
  236. DSP_CODEC_FORMAT_ACT = 8, /* ACT_TYPE */
  237. DSP_CODEC_FORMAT_AMR = 9, /* AMR_TYPE */
  238. DSP_CODEC_FORMAT_SBC = 10, /* SBC_TYPE */
  239. DSP_CODEC_FORMAT_MSBC = 11, /* MSBC_TYPE */
  240. DSP_CODEC_FORMAT_OPUS = 12, /* OPUS_TYPE */
  241. DSP_CODEC_FORMAT_CVSD = 15, /* CVSD_TYPE */
  242. DSP_CODEC_FORMAT_SPEECH = 16, /* CVSD_TYPE */
  243. DSP_CODEC_FORMAT_PCM = 17, /* LDAC_TYPE */
  244. DSP_CODEC_FORMAT_LDAC = 18, /* LDAC_TYPE */
  245. DSP_CODEC_FORMAT_NAV = 19, /* NAV_TYPE */
  246. DSP_CODEC_FORMAT_NAV_SEP = 20, /* NAV_SEP_TYPE */
  247. DSP_CODEC_FORMAT_AAC_M4A = 21, /* m4A_SEP_TYPE */
  248. DSP_CODEC_FORMAT_PCM_DSP = 22, /* PCM_DSP_TYPE */
  249. };
  250. /* session error state */
  251. enum {
  252. MUSIC_PROCESSER = 0,
  253. VOICE_PROCESSER = 1,
  254. };
  255. enum {
  256. RESAMPLE_SAMPLERATE_16 = 16000,
  257. RESAMPLE_SAMPLERATE_44_1 = 44100,
  258. RESAMPLE_SAMPLERATE_48 = 48000,
  259. };
  260. enum {
  261. RESAMPLE_FRAMESZ_44_1 = 441,
  262. RESAMPLE_FRAMESZ_48 = 480,
  263. RESAMPLE_FRAMESZ_16 = 160,
  264. };
  265. enum {
  266. REF_STREAM_NULL = 0,
  267. REF_STREAM_MONO,
  268. REF_STREAM_LEFT,
  269. REF_STREAM_RIGHT,
  270. };
  271. enum {
  272. MIX_MODE_NULL,
  273. MIX_MODE_LEFT_RIGHT, //左右输出
  274. MIX_MODE_LEFT, //左输出
  275. MIX_MODE_RIGHT, //右输出
  276. MIX_MODE_L_R_SWITCH, //左右交换
  277. MIX_MODE_L_R_MERGE, //左右混合
  278. };
  279. enum {
  280. INPUT_FROM_STREAM = 0,
  281. INPUT_FROM_DSP_ADC_FIFO = 1,
  282. INPUT_FROM_DSP_DEC_OUTPUT = 2,
  283. };
  284. enum {
  285. AEC_NOT_INIT = 0,
  286. AEC_CONFIGED,
  287. AEC_START,
  288. };
  289. struct media_dspssn_params {
  290. int16_t aec_en;
  291. } __packed;
  292. struct media_dspssn_info {
  293. struct media_dspssn_params params;
  294. } __packed;
  295. /* test function parameters */
  296. struct test_dspfunc_params {
  297. RINGBUF_TYPE inbuf;
  298. RINGBUF_TYPE refbuf;
  299. RINGBUF_TYPE outbuf;
  300. } __packed;
  301. /* test function runtime */
  302. struct test_dspfunc_runtime {
  303. uint32_t sample_count;
  304. } __packed;
  305. /* test function runtime */
  306. struct test_dspfunc_debug {
  307. RINGBUF_TYPE inbuf;
  308. RINGBUF_TYPE refbuf;
  309. RINGBUF_TYPE outbuf;
  310. } __packed;
  311. /* test function information */
  312. struct test_dspfunc_info {
  313. struct test_dspfunc_params params;
  314. struct test_dspfunc_runtime runtime;
  315. } __packed;
  316. /* decoder resample function parameters */
  317. struct decoder_resample_params{
  318. uint32_t input_sr;
  319. uint32_t output_sr;
  320. uint32_t input_sample_pairs;
  321. uint32_t output_sample_pairs;
  322. } __packed;
  323. /* decoder function parameters */
  324. /* inbuf-->outbuf-->(resbuf)*/
  325. struct decoder_dspfunc_params {
  326. uint16_t slot; /* decoder slot */
  327. uint16_t format;
  328. uint16_t channels;
  329. uint16_t sample_bits;
  330. uint32_t sample_rate;
  331. RINGBUF_TYPE inbuf;
  332. RINGBUF_TYPE resbuf;
  333. RINGBUF_TYPE outbuf;
  334. struct decoder_resample_params resample_param;
  335. } __packed;
  336. /* decoder function extended parameters */
  337. struct decoder_dspfunc_ext_params {
  338. /* format specific parameter buffer */
  339. uint32_t format_pbuf;
  340. uint32_t format_pbufsz;
  341. /* store events passed by decoder */
  342. RINGBUF_TYPE evtbuf;
  343. } __packed;
  344. /* mix channel parameters */
  345. struct mix_channel_params{
  346. //uint16_t master_channel:1;
  347. uint16_t channels:2;
  348. uint16_t vol:6; // 0 ~ 31
  349. uint16_t is_mute:1;
  350. uint16_t mix_mode:3; //MIX_MODE_NULL ...
  351. uint16_t sample_bits:1; //0:16bit, 1:32bit
  352. uint16_t running:1;
  353. uint16_t master_channel:1;
  354. uint16_t reserved:1;
  355. uint16_t input_sr:8;
  356. uint16_t output_sr:8;
  357. RINGBUF_TYPE chan_buf;
  358. RINGBUF_TYPE res_buf;
  359. } __packed;
  360. /* mix function parameters */
  361. struct mix_dspfunc_params{
  362. uint32_t channel_num;
  363. struct mix_channel_params channel_params[DSP_SUPPORT_MULTI_BUFFER_NUM];
  364. } __packed;
  365. /* output function parameters */
  366. struct output_dspfunc_params{
  367. RINGBUF_TYPE outbuf;
  368. RINGBUF_TYPE outbuf_subwoofer;
  369. RINGBUF_TYPE hdrbuf;
  370. uint32_t sample_bits:1; //0:16bit, 1:32bit
  371. uint32_t dac_fifo:4; //0:cpu dma dac fifo, 1:dsp directly dac fifo
  372. //2:cpu dma i2s tx 3:dsp dma to dac fifo
  373. uint32_t latency_calc:1; //1:dsp latency calc
  374. uint32_t reserved:25;
  375. } __packed;
  376. /* energy function parameters */
  377. struct energy_dspfunc_params{
  378. RINGBUF_TYPE energy_buf;
  379. } __packed;
  380. /* decoder function runtime */
  381. struct decoder_dspfunc_runtime {
  382. uint32_t frame_size;
  383. uint32_t channels;
  384. uint32_t sample_count;
  385. uint32_t datalost_count;
  386. uint32_t raw_count;
  387. short dec_channel; //asdec_chn_t
  388. uint16_t dec_channel_change:1;
  389. uint16_t stream_ended:1;
  390. uint16_t stream_ending:1;
  391. uint16_t reserved:13;
  392. } __packed;
  393. /* decoder function debug options */
  394. struct decoder_dspfunc_debug {
  395. RINGBUF_TYPE stream;
  396. RINGBUF_TYPE pcmbuf;
  397. RINGBUF_TYPE plcbuf;
  398. } __packed;
  399. struct decoder_hdr_info {
  400. RINGBUF_TYPE hdrbuf;
  401. int output_sample_bits; //0:16bit, 1:32bit
  402. };
  403. /* decoder function information */
  404. struct decoder_dspfunc_info {
  405. struct decoder_dspfunc_params params;
  406. struct decoder_dspfunc_runtime runtime;
  407. struct decoder_dspfunc_debug debug;
  408. struct decoder_dspfunc_ext_params ext_params;
  409. } __packed;
  410. /* encoder function parameters */
  411. struct encoder_dspfunc_params {
  412. uint16_t slot; /* encoder slot */
  413. uint16_t format;
  414. uint16_t sub_format;
  415. uint16_t sample_bits;
  416. uint16_t sample_rate_orig;
  417. uint16_t sample_rate;
  418. uint32_t bit_rate; /* bps, bits per second */
  419. uint16_t complexity;
  420. uint16_t channels:4;
  421. uint16_t channels_out:4;
  422. uint16_t input_src:8;
  423. uint32_t frame_size;
  424. RINGBUF_TYPE inbuf;
  425. RINGBUF_TYPE outbuf;
  426. } __packed;
  427. /* encoder function ext parameters */
  428. struct encoder_dspfunc_ext_params {
  429. uint32_t *encode_time;
  430. RINGBUF_TYPE header_buf;
  431. } __packed;
  432. /* encoder function runtime */
  433. struct encoder_dspfunc_runtime {
  434. uint32_t frame_size;
  435. uint32_t channels;
  436. uint32_t compression_ratio;
  437. uint32_t sample_count;
  438. } __packed;
  439. /* encoder function debug options */
  440. struct encoder_dspfunc_debug {
  441. RINGBUF_TYPE pcmbuf;
  442. RINGBUF_TYPE stream;
  443. } __packed;
  444. /* encoder function information */
  445. struct encoder_dspfunc_info {
  446. struct encoder_dspfunc_params params;
  447. struct encoder_dspfunc_runtime runtime;
  448. struct encoder_dspfunc_debug debug;
  449. struct encoder_dspfunc_ext_params ext_params;
  450. } __packed;
  451. /* preprocess function information */
  452. struct preprocess_dspfunc_info {
  453. struct encoder_dspfunc_params params;
  454. struct encoder_dspfunc_runtime runtime;
  455. struct encoder_dspfunc_debug debug;
  456. } __packed;
  457. /* dae function parameters */
  458. struct dae_dspfunc_params {
  459. uint32_t pbuf; /* parameter buffer address */
  460. uint32_t pbufsz; /* parameter buffer size */
  461. } __packed;
  462. struct aec_dspfunc_channel_params{
  463. /* aec reference stream type */
  464. int16_t stream_type;
  465. /* ref stream source buffers */
  466. RINGBUF_TYPE srcbuf;
  467. /* ref stream buffers */
  468. RINGBUF_TYPE refbuf;
  469. } __packed;
  470. /* aec refs channel parameters */
  471. struct aec_dspfunc_ref_params{
  472. /* delayed frames */
  473. int16_t delay;
  474. /* ref buffer num */
  475. int16_t channel_num;
  476. /* ref buffer num */
  477. struct aec_dspfunc_channel_params channel[DSP_SUPPORT_AEC_REFBUF_NUM];
  478. } __packed;
  479. /* aec function parameters */
  480. struct aec_dspfunc_params {
  481. /* aec enable or not and aec reterance type */
  482. int16_t enable; //0:disable 1:soft 2:hardware
  483. /* ref buffer num */
  484. int16_t channel_num;
  485. /* aec block size*/
  486. int16_t block_size;
  487. /* dropped count of mic samples to sync with aec reference */
  488. int16_t dropped_samples;
  489. /* mic data buffer */
  490. RINGBUF_TYPE inbuf;
  491. /* ref stream buffers */
  492. RINGBUF_TYPE refbuf[DSP_SUPPORT_AEC_REFBUF_NUM];
  493. /* aec out buffer */
  494. RINGBUF_TYPE outbuf;
  495. } __packed;
  496. /* misc function parameters */
  497. struct misc_dspfunc_parsms {
  498. int16_t auto_mute;
  499. int16_t auto_mute_threshold;
  500. int16_t reserved[2];
  501. }__packed;
  502. /* audio channel parameters */
  503. struct dspfunc_audio_params {
  504. uint16_t aout_volume_changed : 1;
  505. uint16_t aout_mute_changed : 1;
  506. uint16_t aout_mute : 1;
  507. uint16_t aout_fade_changed : 1;
  508. uint16_t aout_fade_mode : 2; //as FADE_STA_NONE, FADE_STA_IN, FADE_STA_OUT
  509. uint16_t reserved : 10;
  510. uint16_t aout_lchvol;
  511. uint16_t aout_rchvol;
  512. uint16_t aout_fade_time; //millisecond
  513. } __packed;
  514. /* play ontime mode */
  515. enum {
  516. PLAY_ONTIME_LATENCY = 0,
  517. PLAY_ONTIME_TIMESTAMP = 1,
  518. PLAY_ONTIME_DELAY = 2,
  519. };
  520. /* dsp play on time parameters */
  521. struct dspfunc_play_ontime_params {
  522. uint32_t play_ontime_enable : 1;
  523. uint32_t play_ontime_mode : 2;
  524. uint32_t reserved : 29;
  525. uint32_t time_val_lo;
  526. uint32_t time_val_hi;
  527. uint16_t *play_flag;
  528. } __packed;
  529. /* postprocessor function parameters */
  530. struct streamout_dspfunc_params {
  531. struct dae_dspfunc_params dae;
  532. struct aec_dspfunc_ref_params aec_ref;
  533. struct output_dspfunc_params output;
  534. struct mix_dspfunc_params mix;
  535. struct energy_dspfunc_params energy;
  536. struct misc_dspfunc_parsms misc;
  537. struct dspfunc_audio_params audio;
  538. struct dspfunc_play_ontime_params play_ontime;
  539. } __packed;
  540. struct streamout_dspfunc_runtime_pcmbuf {
  541. uint16_t cpu_read_seq;
  542. uint16_t dsp_write_seq;
  543. uint16_t packet_num;
  544. uint16_t frame_num;
  545. uint32_t latency_us;
  546. uint32_t time_stamp_us;
  547. } __packed;
  548. /* postprocessor function runtime */
  549. struct streamout_dspfunc_runtime {
  550. uint16_t fromat;
  551. uint16_t sample_rate;
  552. uint16_t frame_size;
  553. uint16_t channels : 2;
  554. uint16_t sample_bits : 2; //0:16bit, 1:32bit
  555. uint16_t sample_size16_shift : 4; //log2(size16) of one sample pair, 2 for 32bits stereo, 0 for 32bits mono or 16bits stereo, 1 for 16bits mono
  556. uint16_t stream_ending:1;
  557. uint16_t stream_buf_low:1;
  558. uint16_t reserved : 6;
  559. struct dsp_ringbuf *decoder_input;
  560. struct dsp_ringbuf *postprocess_input;
  561. struct dsp_ringbuf *postprocess_outbuf;
  562. struct dsp_ringbuf *second_output;
  563. struct streamout_dspfunc_runtime_pcmbuf pcmbuf;
  564. } __packed;
  565. /* postprocessor function debug options */
  566. struct streamout_dspfunc_debug {
  567. RINGBUF_TYPE ref_data;
  568. RINGBUF_TYPE dae_data;
  569. } __packed;
  570. /* encoder function information */
  571. struct streamout_dspfunc_info {
  572. struct streamout_dspfunc_params params;
  573. struct streamout_dspfunc_runtime runtime;
  574. struct streamout_dspfunc_debug debug;
  575. } __packed;
  576. /* postprocessor function parameters */
  577. struct preprocess_dspfunc_params {
  578. struct dae_dspfunc_params dae;
  579. struct aec_dspfunc_params aec;
  580. } __packed;
  581. /* postprocessor function runtime */
  582. struct preprocess_dspfunc_runtime {
  583. uint16_t fromat;
  584. uint16_t sample_rate;
  585. } __packed;
  586. /* postprocessor function debug options */
  587. struct preprocess_dspfunc_debug {
  588. RINGBUF_TYPE mic1_data;
  589. RINGBUF_TYPE mic2_data;
  590. RINGBUF_TYPE ref_data;
  591. RINGBUF_TYPE aec1_data;
  592. RINGBUF_TYPE aec2_data;
  593. RINGBUF_TYPE res_in_stream;
  594. RINGBUF_TYPE res_out_stream;
  595. } __packed;
  596. /* player function debug options */
  597. struct player_dspfunc_debug {
  598. RINGBUF_TYPE decode_stream;
  599. RINGBUF_TYPE decode_data;
  600. RINGBUF_TYPE plc_data;
  601. RINGBUF_TYPE dae_data;
  602. } __packed;
  603. /* player function information */
  604. struct player_dspfunc_info {
  605. struct dae_dspfunc_params dae;
  606. struct aec_dspfunc_ref_params aec_ref;
  607. struct output_dspfunc_params output;
  608. const struct decoder_dspfunc_info *decoder_info;
  609. struct mix_dspfunc_params mix;
  610. struct player_dspfunc_debug debug;
  611. struct energy_dspfunc_params energy;
  612. const struct streamout_dspfunc_info *streamout_info;
  613. } __packed;
  614. /* recorder function debug options */
  615. struct recorder_dspfunc_debug {
  616. RINGBUF_TYPE mic1_data;
  617. RINGBUF_TYPE mic2_data;
  618. RINGBUF_TYPE ref_data;
  619. RINGBUF_TYPE aec1_data;
  620. RINGBUF_TYPE aec2_data;
  621. RINGBUF_TYPE encode_data;
  622. RINGBUF_TYPE encode_stream;
  623. RINGBUF_TYPE res_in_stream;
  624. RINGBUF_TYPE res_out_stream;
  625. } __packed;
  626. /* recorder function information */
  627. struct recorder_dspfunc_info {
  628. struct dae_dspfunc_params dae;
  629. struct aec_dspfunc_params aec;
  630. const struct preprocess_dspfunc_info * preprocess_info;
  631. const struct encoder_dspfunc_info * encoder_info;
  632. void *res_handle;
  633. short res_input_samples;
  634. short res_output_samples;
  635. RINGBUF_TYPE res_inbuf;
  636. RINGBUF_TYPE res_outbuf;
  637. struct recorder_dspfunc_debug debug;
  638. } __packed;
  639. /* dsp sleep parameters */
  640. struct dspfunc_sleep_params {
  641. uint16_t sleep_enable;
  642. uint16_t sleep_mode : 2; /* 0 is light sleep, 1 is deep sleep*/
  643. uint16_t sleep_stat_log : 1; /* log statistics dsp sleep time in 1,000,000 us */
  644. uint16_t sleep_debug_log : 1; /* log dsp sleep details */
  645. uint16_t reserved : 12;
  646. uint16_t idle_sleep_time_us;
  647. uint16_t nodata_sleep_time_us;
  648. } __packed;
  649. #ifdef __cplusplus
  650. }
  651. #endif
  652. #endif /* _DSP_HAL_DEFS_H_ */