1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __CP_SERVER_H__ 6 #define __CP_SERVER_H__ 7 8 #if defined(CHIP_HAS_CP) 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #define CP_BUF_LEN 0x2000 15 16 typedef void (*CP_TASK_T)(void *param); 17 18 typedef enum { 19 CP_TASK_ID_INVALID, 20 CP_TASK_ID_MP3, 21 CP_TASK_ID_AAC_ADTS, 22 CP_TASK_ID_OPUS_DEC, 23 CP_TASK_ID_OPUS_ENC, 24 CP_TASK_ID_EQ_DRC, 25 #ifdef VOIP_ALG_IN_CP 26 CP_TASK_ID_VOIP_ALG, 27 #endif 28 CP_TASK_ID_RESAMP, 29 CP_TASK_ID_NUM, 30 }CP_TASK_ID_T; 31 32 #ifdef MP3_DECODE_IN_CP 33 typedef struct { 34 uint32_t decoder_hander_addr; 35 uint32_t mp3_bytes; 36 uint32_t out_pcm_addr; 37 uint32_t out_mp3_info_addr; 38 uint32_t in_buf_addr; 39 int32_t result; 40 uint8_t buf_location; 41 }CP_MSG_MP3_DEC_T; 42 #endif 43 44 #ifdef AAC_DECODE_IN_CP 45 typedef struct { 46 uint32_t decoder_hander_addr; 47 uint32_t in_buf_addr; 48 uint32_t in_buf_size_addr; 49 uint32_t in_buf_valid_addr; 50 uint32_t out_buf_addr; 51 int32_t out_buf_size; 52 int32_t flags; 53 int32_t result; 54 uint8_t buf_location; 55 }CP_MSG_AAC_DEC_T; 56 #endif 57 58 #ifdef OPUS_DECODE_IN_CP 59 typedef struct { 60 uint32_t decoder_hander_addr; 61 uint32_t in_buf_addr; 62 uint32_t in_buf_size; 63 uint32_t out_buf_addr; 64 uint32_t out_buf_size; 65 int32_t decode_fec; 66 int32_t result; 67 uint8_t buf_location; 68 }CP_MSG_OPUS_DEC_T; 69 #endif 70 71 #ifdef OPUS_ENCODE_IN_CP 72 typedef struct { 73 uint32_t handler_addr; 74 uint32_t in_buf_addr; 75 uint32_t in_buf_size; 76 uint32_t buf_size; 77 uint32_t out_buf_addr; 78 int32_t max_data_bytes; 79 int32_t result; 80 uint8_t buf_location; 81 }CP_MSG_OPUS_ENC_T; 82 #endif 83 84 #ifdef VOIP_ALG_IN_CP 85 typedef struct { 86 uint32_t decoder_hander_addr; 87 uint32_t near_buf_addr; 88 uint32_t far_buf_addr; 89 uint32_t out_buf_addr; 90 uint32_t buf_size; 91 int32_t result; 92 uint8_t buf_location; 93 }CP_MSG_VOIP_ALG_T; 94 #endif 95 96 #ifdef EQ_DRC_IN_CP 97 typedef struct { 98 uint32_t buf_addr; 99 uint32_t buf_len; 100 int32_t result; 101 }CP_MSG_EQ_DRC_T; 102 #endif 103 104 #ifdef ALSA_RESAMPLE_IN_CP 105 typedef struct { 106 uint32_t handler_addr; 107 uint32_t io_addr; 108 uint32_t in_size; 109 uint32_t out_size; 110 int32_t result; 111 uint8_t buf_location; 112 }CP_MSG_RESAMP_T; 113 #endif 114 115 typedef struct { 116 CP_TASK_ID_T id; 117 uint32_t buf[CP_BUF_LEN/4]; 118 }CP_MSG_T; 119 120 121 int cp_server_init(); 122 void cp_server_register_task(CP_TASK_ID_T id, CP_TASK_T task_handler); 123 int cp_server_send_msg_to_cp(CP_TASK_ID_T id, void *msg); 124 125 void *cp_heap_malloc(uint32_t size); 126 void *cp_heap_calloc(uint32_t count, uint32_t size); 127 void cp_heap_free(void *p); 128 void *cp_heap_realloc(void *p, uint32_t size); 129 void cp_heap_memory_info(uint32_t *total, uint32_t *used, uint32_t *max_used); 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif 136 #endif 137