rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame^] | 1 | |
| 2 | #include "l1aud_common_def.h" |
| 3 | #include "kal_public_api.h" |
| 4 | #include "kal_general_types.h" |
| 5 | #include "kal_trace.h" |
| 6 | #include "l1sp_trc.h" |
| 7 | |
| 8 | #include "speech_service.h" |
| 9 | #include "audio_msgid.h" |
| 10 | #include "dhl_trace.h" |
| 11 | #include "svc_sap.h" |
| 12 | |
| 13 | extern kal_uint16 L1Audio_GetDebugInfo( kal_uint8 index ); |
| 14 | extern void dhl_log_primitive(ilm_struct *ilm); |
| 15 | |
| 16 | SPLog_t SPLog; |
| 17 | kal_uint16 bt_tx_seq = 0; |
| 18 | kal_uint16 bt_rx_seq = 0; |
| 19 | |
| 20 | |
| 21 | /* API definition */ |
| 22 | void SPLog_GetFlagSetting() |
| 23 | { |
| 24 | #ifdef __MODEM_LOGGING_SUPPORT__ |
| 25 | SPLog.flag = L1Audio_GetDebugInfo(1); |
| 26 | MD_TRC_SPLOG_GET_DBG_FLAG(SPLog.flag); |
| 27 | // kal_prompt_trace(MOD_L1SP, "[DBG_LOG]flag %x, msg_begin id %d\r\n", SPLog.flag, MSG_ID_AUDIO_LOGGING_BEGIN); |
| 28 | #else |
| 29 | #endif |
| 30 | } |
| 31 | |
| 32 | void SPLog_LogSingleData(kal_uint32 msg_id, kal_uint32 data_length, void *data) |
| 33 | { |
| 34 | #ifdef __MODEM_LOGGING_SUPPORT__ |
| 35 | if(SPLog.flag & (1 << (msg_id - MSG_ID_AUDIO_LOGGING_BEGIN -1))) |
| 36 | { |
| 37 | ilm_struct current_ilm; |
| 38 | singleData_struct *local_para; |
| 39 | kal_uint32 i; |
| 40 | |
| 41 | // kal_prompt_trace(MOD_L1SP, "[SP_LOG_SINGLE]ID %x", msg_id); |
| 42 | current_ilm.src_mod_id = MOD_L1SP; |
| 43 | current_ilm.dest_mod_id = MOD_DHL_READER; |
| 44 | current_ilm.sap_id = INVALID_SAP; |
| 45 | current_ilm.msg_id = msg_id; |
| 46 | current_ilm.peer_buff_ptr = NULL; |
| 47 | |
| 48 | current_ilm.local_para_ptr = construct_local_para(sizeof(singleData_struct),TD_CTRL); |
| 49 | local_para = (singleData_struct *)current_ilm.local_para_ptr; |
| 50 | |
| 51 | local_para->local_hdr_len = 4; /*size of LOCAL_PARA_HDR */ |
| 52 | local_para->data_len = data_length; |
| 53 | for(i = 0; i < data_length; i++){ |
| 54 | local_para->data[i] = *((kal_uint8 *)data+i); |
| 55 | } |
| 56 | |
| 57 | dhl_log_primitive(¤t_ilm); |
| 58 | destroy_ilm(¤t_ilm); |
| 59 | } |
| 60 | #else |
| 61 | #endif |
| 62 | } |
| 63 | |
| 64 | void SPLog_LogData(kal_uint32 msg_id, kal_uint32 data_length, void *data) |
| 65 | { |
| 66 | #ifdef __MODEM_LOGGING_SUPPORT__ |
| 67 | if(SPLog.flag & (1 << (msg_id - MSG_ID_AUDIO_LOGGING_BEGIN -1))) |
| 68 | { |
| 69 | ilm_struct current_ilm; |
| 70 | data_struct *local_para; |
| 71 | kal_uint32 i; |
| 72 | |
| 73 | // kal_prompt_trace(MOD_L1SP, "[SP_LOG_DATA]ID %x", msg_id); |
| 74 | current_ilm.src_mod_id = MOD_L1SP; |
| 75 | current_ilm.dest_mod_id = MOD_DHL_READER; |
| 76 | current_ilm.sap_id = INVALID_SAP; |
| 77 | current_ilm.msg_id = msg_id; |
| 78 | current_ilm.peer_buff_ptr = NULL; |
| 79 | |
| 80 | current_ilm.local_para_ptr = construct_local_para(sizeof(data_struct),TD_CTRL); |
| 81 | local_para = (data_struct *)current_ilm.local_para_ptr; |
| 82 | local_para->local_hdr_len = 4; // size of LOCAL_PARA_HDR |
| 83 | local_para->opcode = 1; //0: header 1: data log 2:end |
| 84 | switch(msg_id) { |
| 85 | case MSG_ID_AUDIO_LOGGING_BT_TX: |
| 86 | local_para->log_seq = bt_tx_seq++; |
| 87 | break; |
| 88 | case MSG_ID_AUDIO_LOGGING_BT_RX: |
| 89 | local_para->log_seq = bt_rx_seq++; |
| 90 | break; |
| 91 | default: |
| 92 | local_para->log_seq = 0; |
| 93 | break; |
| 94 | } |
| 95 | local_para->data_len = data_length; |
| 96 | for(i = 0; i < data_length; i++){ |
| 97 | local_para->data[i] = *((kal_uint8 *)data+i); |
| 98 | } |
| 99 | dhl_log_primitive(¤t_ilm); |
| 100 | destroy_ilm(¤t_ilm); |
| 101 | } |
| 102 | #else |
| 103 | #endif |
| 104 | } |
| 105 | void SPLog_LogDbgInfo(kal_uint32 msg_id, kal_uint8 opcode, void *data) |
| 106 | { |
| 107 | #ifdef __MODEM_LOGGING_SUPPORT__ |
| 108 | if(SPLog.flag & (1 << (msg_id - MSG_ID_AUDIO_LOGGING_BEGIN -1))) |
| 109 | { |
| 110 | ilm_struct current_ilm; |
| 111 | dbgInfo_struct *local_para; |
| 112 | kal_uint32 i; |
| 113 | |
| 114 | // kal_prompt_trace(MOD_L1SP, "[SP_DBG_INFO]ID %x", msg_id); |
| 115 | current_ilm.src_mod_id = MOD_L1SP; |
| 116 | current_ilm.dest_mod_id = MOD_DHL_READER; |
| 117 | current_ilm.sap_id = INVALID_SAP; |
| 118 | current_ilm.msg_id = msg_id; |
| 119 | current_ilm.peer_buff_ptr = NULL; |
| 120 | |
| 121 | current_ilm.local_para_ptr = construct_local_para(sizeof(dbgInfo_struct),TD_CTRL); |
| 122 | local_para = (dbgInfo_struct *)current_ilm.local_para_ptr; |
| 123 | |
| 124 | local_para->local_hdr_len = 4; //size of LOCAL_PARA_HDR |
| 125 | local_para->opcode = opcode; //0: header 1: data log 2:end |
| 126 | for(i = 0; i < 2; i++){ |
| 127 | local_para->reserved[i] = *((kal_uint8 *)data+i); |
| 128 | } |
| 129 | |
| 130 | dhl_log_primitive(¤t_ilm); |
| 131 | destroy_ilm(¤t_ilm); |
| 132 | } |
| 133 | #else |
| 134 | #endif |
| 135 | } |
| 136 | |
| 137 | |