b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /****************************************************************************** |
| 2 | *(C) Copyright 2014 Marvell International Ltd. |
| 3 | * All Rights Reserved |
| 4 | ******************************************************************************/ |
| 5 | /* ------------------------------------------------------------------------------------------------------------------- |
| 6 | * |
| 7 | * Filename: audio_if_api.h |
| 8 | * |
| 9 | * Authors: tzahi stern |
| 10 | * |
| 11 | * Description: audio_if api to send commands to audio-HAL and VCM |
| 12 | * |
| 13 | * HISTORY: |
| 14 | * |
| 15 | * |
| 16 | * Notes: |
| 17 | * |
| 18 | ******************************************************************************/ |
| 19 | #ifndef AUDIO_IF_API_H |
| 20 | #define AUDIO_IF_API_H |
| 21 | |
| 22 | #define ID_RIFF 0x46464952 |
| 23 | #define ID_WAVE 0x45564157 |
| 24 | #define ID_FMT 0x20746d66 |
| 25 | #define ID_DATA 0x61746164 |
| 26 | |
| 27 | struct riff_wave_header { |
| 28 | unsigned int riff_id; |
| 29 | unsigned int riff_sz; |
| 30 | unsigned int wave_id; |
| 31 | }; |
| 32 | |
| 33 | struct chunk_header { |
| 34 | unsigned int id; |
| 35 | unsigned int sz; |
| 36 | }; |
| 37 | |
| 38 | struct chunk_fmt { |
| 39 | unsigned short audio_format; |
| 40 | unsigned short num_channels; |
| 41 | unsigned int sample_rate; |
| 42 | unsigned int byte_rate; |
| 43 | unsigned short block_align; |
| 44 | unsigned short bits_per_sample; |
| 45 | }; |
| 46 | |
| 47 | struct wav_header { |
| 48 | unsigned int riff_id; |
| 49 | unsigned int riff_sz; |
| 50 | unsigned int riff_fmt; |
| 51 | unsigned int fmt_id; |
| 52 | unsigned int fmt_sz; |
| 53 | unsigned short audio_format; |
| 54 | unsigned short num_channels; |
| 55 | unsigned int sample_rate; |
| 56 | unsigned int byte_rate; |
| 57 | unsigned short block_align; |
| 58 | unsigned short bits_per_sample; |
| 59 | unsigned int data_id; |
| 60 | unsigned int data_sz; |
| 61 | }; |
| 62 | |
| 63 | typedef enum |
| 64 | { |
| 65 | PCM_SWITCH_TYPE_PCM_OFF = 0, /* with slic, off the PCM */ |
| 66 | PCM_SWITCH_TYPE_PCM_ON, /* with slic, on the PCM, and NB */ |
| 67 | PCM_SWITCH_TYPE_PCM_ON_WB, /* with slic, on the PCM, and WB */ |
| 68 | PCM_SWITCH_TYPE_PCM_OFF_WITHOUT_SLIC, /* without slic, off the PCM */ |
| 69 | PCM_SWITCH_TYPE_PCM_OFF_WITH_CODEC, /* with codec, Off the PCM */ |
| 70 | PCM_SWITCH_TYPE_PCM_ON_WITH_CODEC, /* with codec, On the PCM */ |
| 71 | |
| 72 | MAX_PCM_SWITCH_TYPE = PCM_SWITCH_TYPE_PCM_ON_WITH_CODEC |
| 73 | } PCM_SWITCH_TYPE; |
| 74 | |
| 75 | typedef enum |
| 76 | { |
| 77 | DTMF_DETECTION_TX_OFF = 0, /* OFF TX DTMF DETECTION */ |
| 78 | DTMF_DETECTION_TX_ON, /* ON TX DTMF DETECTION */ |
| 79 | DTMF_DETECTION_RX_OFF, /* OFF RX DTMF DETECTION */ |
| 80 | DTMF_DETECTION_RX_ON, /* ON RX DTMF DETECTION */ |
| 81 | } DTMF_DETECTION_TYPE; |
| 82 | |
| 83 | #define UNUSEDPARAM(param) (void)param; |
| 84 | #define UNUSEDFUNC(func) (void)&func; |
| 85 | |
| 86 | /**************** functions for methods invokation ************/ |
| 87 | int audio_if_audio_mode_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 88 | struct ubus_request_data *req, const char *method, |
| 89 | struct blob_attr *msg); |
| 90 | int audio_if_audio_mode_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 91 | struct ubus_request_data *req, const char *method, |
| 92 | struct blob_attr *msg); |
| 93 | int audio_if_audio_device_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 94 | struct ubus_request_data *req, const char *method, |
| 95 | struct blob_attr *msg); |
| 96 | int audio_if_audio_device_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 97 | struct ubus_request_data *req, const char *method, |
| 98 | struct blob_attr *msg); |
| 99 | int audio_if_tty_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 100 | struct ubus_request_data *req, const char *method, |
| 101 | struct blob_attr *msg); |
| 102 | int audio_if_volume_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 103 | struct ubus_request_data *req, const char *method, |
| 104 | struct blob_attr *msg); |
| 105 | int audio_if_volume_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 106 | struct ubus_request_data *req, const char *method, |
| 107 | struct blob_attr *msg); |
| 108 | int audio_if_mute_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 109 | struct ubus_request_data *req, const char *method, |
| 110 | struct blob_attr *msg); |
| 111 | int audio_if_mute_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 112 | struct ubus_request_data *req, const char *method, |
| 113 | struct blob_attr *msg); |
| 114 | |
| 115 | /* eCall control */ |
| 116 | int audio_if_ecall_data_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 117 | struct ubus_request_data *req, const char *method, |
| 118 | struct blob_attr *msg); |
| 119 | int audio_if_ecall_data_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 120 | struct ubus_request_data *req, const char *method, |
| 121 | struct blob_attr *msg); |
| 122 | int audio_if_ecall_voice_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 123 | struct ubus_request_data *req, const char *method, |
| 124 | struct blob_attr *msg); |
| 125 | int audio_if_ecall_voice_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 126 | struct ubus_request_data *req, const char *method, |
| 127 | struct blob_attr *msg); |
| 128 | |
| 129 | void audio_if_ecall_data_status_response(void * p_atc_ecall_msg); |
| 130 | void audio_if_ecall_voice_status_response(void * p_atc_ecall_msg); |
| 131 | |
| 132 | int audio_if_switch_pcm(struct ubus_context *ctx, struct ubus_object *obj, |
| 133 | struct ubus_request_data *req, const char *method, |
| 134 | struct blob_attr *msg); |
| 135 | |
| 136 | |
| 137 | /* CP audio path control (play/rec/loopback) */ |
| 138 | int audio_if_vcm_rec_start(struct ubus_context *ctx, struct ubus_object *obj, |
| 139 | struct ubus_request_data *req, const char *method, |
| 140 | struct blob_attr *msg); |
| 141 | int audio_if_vcm_rec_stop(struct ubus_context *ctx, struct ubus_object *obj, |
| 142 | struct ubus_request_data *req, const char *method, |
| 143 | struct blob_attr *msg); |
| 144 | int audio_if_vcm_play_start(struct ubus_context *ctx, struct ubus_object *obj, |
| 145 | struct ubus_request_data *req, const char *method, |
| 146 | struct blob_attr *msg); |
| 147 | int audio_if_vcm_play_stop(struct ubus_context *ctx, struct ubus_object *obj, |
| 148 | struct ubus_request_data *req, const char *method, |
| 149 | struct blob_attr *msg); |
| 150 | int audio_if_cp_loopback_enable(struct ubus_context *ctx, struct ubus_object *obj, |
| 151 | struct ubus_request_data *req, const char *method, |
| 152 | struct blob_attr *msg); |
| 153 | int audio_if_cp_loopback_disable(struct ubus_context *ctx, struct ubus_object *obj, |
| 154 | struct ubus_request_data *req, const char *method, |
| 155 | struct blob_attr *msg); |
| 156 | int audio_if_vcm_configure(struct ubus_context *ctx, struct ubus_object *obj, |
| 157 | struct ubus_request_data *req, const char *method, |
| 158 | struct blob_attr *msg); |
| 159 | int audio_if_DTMFDetection(struct ubus_context *ctx, struct ubus_object *obj, |
| 160 | struct ubus_request_data *req, const char *method, |
| 161 | struct blob_attr *msg); |
| 162 | |
| 163 | int audio_if_pcmloopback_start(struct ubus_context *ctx, struct ubus_object *obj, |
| 164 | struct ubus_request_data *req, const char *method, |
| 165 | struct blob_attr *msg); |
| 166 | int audio_if_pcmloopback_stop(struct ubus_context *ctx, struct ubus_object *obj, |
| 167 | struct ubus_request_data *req, const char *method, |
| 168 | struct blob_attr *msg); |
| 169 | int audio_if_config_pcm(struct ubus_context *ctx, struct ubus_object *obj, |
| 170 | struct ubus_request_data *req, const char *method, |
| 171 | struct blob_attr *msg); |
| 172 | int audio_if_config_dspgain(struct ubus_context *ctx, struct ubus_object *obj, |
| 173 | struct ubus_request_data *req, const char *method, |
| 174 | struct blob_attr *msg); |
| 175 | int audio_if_config_pcmexpert(struct ubus_context *ctx, struct ubus_object *obj, |
| 176 | struct ubus_request_data *req, const char *method, |
| 177 | struct blob_attr *msg); |
| 178 | int audio_if_DTMFControl(struct ubus_context *ctx, struct ubus_object *obj, |
| 179 | struct ubus_request_data *req, const char *method, |
| 180 | struct blob_attr *msg); |
| 181 | int audio_if_report_voice_status(struct ubus_context *ctx, struct ubus_object *obj, |
| 182 | struct ubus_request_data *req, const char *method, |
| 183 | struct blob_attr *msg); |
| 184 | |
| 185 | int audio_if_reload_nvm(struct ubus_context *ctx, struct ubus_object *obj, |
| 186 | struct ubus_request_data *req, const char *method, |
| 187 | struct blob_attr *msg); |
| 188 | |
| 189 | int audio_if_config_pa(struct ubus_context *ctx, struct ubus_object *obj, |
| 190 | struct ubus_request_data *req, const char *method, |
| 191 | struct blob_attr *msg); |
| 192 | |
| 193 | #ifdef TARGET_mmp_asr1901_KSTR901 |
| 194 | int audio_if_adsp_set(struct ubus_context *ctx, struct ubus_object *obj, |
| 195 | struct ubus_request_data *req, const char *method, |
| 196 | struct blob_attr *msg); |
| 197 | int audio_if_adsp_send_ve(struct ubus_context *ctx, struct ubus_object *obj, |
| 198 | struct ubus_request_data *req, const char *method, |
| 199 | struct blob_attr *msg); |
| 200 | int audio_if_adsp_dump_full_ddr(struct ubus_context *ctx, struct ubus_object *obj, |
| 201 | struct ubus_request_data *req, const char *method, |
| 202 | struct blob_attr *msg); |
| 203 | #endif |
| 204 | |
| 205 | #endif //AUDIO_IF_API_H |