1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __TRANSQ_MSG_H__ 6 #define __TRANSQ_MSG_H__ 7 8 #if defined(CHIP_HAAS1000) 9 #include "hal_transq.h" 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 typedef void (*TRANSQ_MSG_HANDLE_CB_T)(void *param); 16 17 typedef enum { 18 TRANSQ_MSG_TYPE_TRACE, 19 TRANSQ_MSG_TYPE_AF_OPEN, 20 TRANSQ_MSG_TYPE_AF_CLOSE, 21 TRANSQ_MSG_TYPE_AF_CAPTURE_START, 22 TRANSQ_MSG_TYPE_AF_CAPTURE_STOP, 23 TRANSQ_MSG_TYPE_AF_PLAYBACK_START, 24 TRANSQ_MSG_TYPE_AF_PLAYBACK_STOP, 25 TRANSQ_MSG_TYPE_AF_CAPTURE_IRQ, 26 TRANSQ_MSG_TYPE_AF_PLAYBACK_IRQ, 27 TRANSQ_MSG_TYPE_RECORD_DATA, 28 TRANSQ_MSG_TYPE_USERDATA, 29 TRANSQ_MSG_TYPE_VOIP, 30 TRANSQ_MSG_TYPE_KEY, 31 TRANSQ_MSG_TYPE_CMD, 32 TRANSQ_MSG_TYPE_AUDIO_DUMP, 33 TRANSQ_MSG_TYPE_HEARTBEAT, 34 TRANSQ_MSG_TYPE_AUDIO_DUMP_ONE_CHANNEL, 35 TRANSQ_MSG_TYPE_NUM, 36 }TRANSQ_MSG_TYPE_T; 37 38 struct TRANSQ_MSG_TRACE { 39 unsigned int addr; 40 unsigned int len; 41 }; 42 43 struct TRANSQ_MSG_AF_CONFIG_T { 44 unsigned int bits; 45 unsigned int sample_rate; 46 unsigned int channel_num; 47 unsigned int channel_map; 48 unsigned int device; 49 unsigned int io_path; 50 bool chan_sep_buf; 51 bool i2s_master_clk_wait; 52 unsigned char i2s_sample_cycles; 53 unsigned char *data_ptr; 54 unsigned int data_size; 55 56 //should define type 57 unsigned char vol; 58 }; 59 60 struct TRANSQ_MSG_AF_BUF { 61 unsigned char *buf; 62 unsigned int len; 63 }; 64 65 66 struct TRANSQ_MSG{ 67 struct TRANSQ_MSG_TRACE trace; 68 struct TRANSQ_MSG_AF_CONFIG_T stream_cfg; 69 struct TRANSQ_MSG_AF_BUF stream_buf; 70 }; 71 72 typedef struct { 73 TRANSQ_MSG_TYPE_T type; 74 enum HAL_TRANSQ_PRI_T pri; 75 unsigned int id; 76 struct TRANSQ_MSG msg; 77 void *user_data; 78 unsigned int user_data_len; 79 unsigned char sync; 80 } TRANSQ_MSG_T; 81 82 #ifndef RTOS 83 #define transq_msg_tx_wait_done(p) \ 84 do{ \ 85 transq_tx_done = 0; \ 86 if(transq_msg_tx(p)) { \ 87 while (!transq_tx_done) { \ 88 hal_sys_timer_delay(MS_TO_TICKS(1)); \ 89 } \ 90 hal_sys_timer_delay(MS_TO_TICKS(1)); \ 91 } \ 92 }while(0) 93 #else 94 #define transq_msg_tx_wait_done(p) \ 95 do{ \ 96 if(transq_msg_tx(p)) { \ 97 if (transq_tx_sem != NULL) { \ 98 osSemaphoreWait(transq_tx_sem, osWaitForever); \ 99 } \ 100 } \ 101 }while(0) 102 #endif 103 104 int transq_msg_init(); 105 int transq_msg_reinit(); 106 int transq_msg_flush(); 107 void transq_msg_onoff(int onoff); 108 int transq_msg_tx(TRANSQ_MSG_T *msg); 109 void transq_msg_register(TRANSQ_MSG_TYPE_T type, TRANSQ_MSG_HANDLE_CB_T func, bool tx); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif 116 #endif 117