MT2523 API Reference  LinkIt SDK v4
hal_audio.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_AUDIO_H__
36 #define __HAL_AUDIO_H__
37 #include "hal_platform.h"
38 
39 #ifdef HAL_AUDIO_MODULE_ENABLED
40 
181 #include <stdio.h>
182 #include <stdint.h>
183 #include <stdbool.h>
184 
185 #ifdef __cplusplus
186 extern "C" {
187 #endif
188 
189 
195 typedef enum {
200 
202 typedef enum {
210 
212 typedef enum {
225 
227 typedef enum {
235 
237 typedef enum {
241 
243 typedef enum {
255 
257 typedef enum {
261 
263 typedef enum {
270 
272 typedef enum {
279 
280 
290 typedef struct {
296  uint32_t analog_gain_index;
298 
300 typedef struct {
305  bool loopback;
307 
308 
310 typedef struct {
311  void* user_data;
312  uint8_t *buffer;
313  uint32_t buffer_size;
314  uint32_t sample_rate;
315  uint32_t channel;
317 
332 typedef void (*hal_audio_stream_out_callback_t)(hal_audio_event_t event, void *user_data);
333 
340 typedef void (*hal_audio_stream_in_callback_t)(hal_audio_event_t event, void *user_data);
341 
349 
361 
368 
376 
385 
392 
400 
405 void hal_audio_stop_stream_out(void);
406 
413 hal_audio_status_t hal_audio_set_stream_out_volume(uint32_t digital_volume_index, uint32_t analog_volume_index);
414 
422 void hal_audio_mute_stream_out(bool mute);
423 
430 
438 hal_audio_status_t hal_audio_write_stream_out(const void *buffer, uint32_t size);
439 
448 
456 
467 
477 
488 
496 void hal_audio_stop_stream_in(void);
497 
504 hal_audio_status_t hal_audio_set_stream_in_volume(uint32_t digital_volume_index, uint32_t analog_volume_index);
505 
513 void hal_audio_mute_stream_in(bool mute);
514 
524 
532 hal_audio_status_t hal_audio_read_stream_in(void *buffer, uint32_t sample_count);
533 
542 
553 
561 hal_audio_status_t hal_audio_get_memory_size(uint32_t *memory_size);
562 
571 
578 hal_audio_status_t hal_audio_get_audio_clock(uint32_t *sample_count);
579 
580 #ifdef __cplusplus
581 }
582 #endif
583 
588 #endif /*HAL_AUDIO_MODULE_ENABLED*/
589 #endif /*__HAL_AUDIO_H__*/
24000Hz
Definition: hal_audio.h:249
22050Hz
Definition: hal_audio.h:248
Stream in: dual digital mic.
Definition: hal_audio.h:222
hal_audio_status_t hal_audio_set_stream_in_channel_number(hal_audio_channel_number_t channel_number)
Set audio input channel number.
hal_audio_status_t hal_audio_register_stream_in_callback(hal_audio_stream_in_callback_t callback, void *user_data)
Register the callback function for input data.
void * user_data
User data provied by user.
Definition: hal_audio.h:311
Audio playback: music.
Definition: hal_audio.h:273
hal_audio_status_t hal_audio_get_audio_clock(uint32_t *sample_count)
Get audio clock.
Stream out:loudspeaker, stereo to mono L=R=(R+L)/2.
Definition: hal_audio.h:218
32000Hz
Definition: hal_audio.h:250
hal_audio_status_t
Audio status.
Definition: hal_audio.h:195
Voice playback: voice.
Definition: hal_audio.h:274
hal_audio_status_t hal_audio_get_memory_size(uint32_t *memory_size)
Query the size of needed memory to be allocated for internal use in audio driver. ...
Stream out:receiver.
Definition: hal_audio.h:216
Stream out:earphone, stereo.
Definition: hal_audio.h:219
hal_audio_status_t hal_audio_set_memory(void *memory)
Hand over allocated memory to audio driver.
This value means notify user rx data is ready.
Definition: hal_audio.h:207
hal_audio_status_t hal_audio_set_stream_out_channel_number(hal_audio_channel_number_t channel_number)
Set the audio output channel number.
hal_audio_channel_number_t
audio channel number define
Definition: hal_audio.h:263
void hal_audio_stop_stream_out(void)
Power off the stream out path.
uint32_t sample_rate
Stream out data sampling rate.
Definition: hal_audio.h:314
hal_audio_status_t hal_audio_read_stream_in(void *buffer, uint32_t sample_count)
Recieve data from the audio input.
Stream in: main mic.
Definition: hal_audio.h:214
uint32_t digital_gain_index
Digital gain index of the audio stream.
Definition: hal_audio.h:295
hal_audio_sampling_rate_t stream_sampling_rate
Specifies the sampling rate of audio data.
Definition: hal_audio.h:291
16 bps
Definition: hal_audio.h:258
Mute earphone mic.
Definition: hal_audio.h:229
hal_audio_device_t
Audio device.
Definition: hal_audio.h:212
hal_audio_status_t hal_audio_set_stream_in_sampling_rate(hal_audio_sampling_rate_t sample_rate)
Set audio input stream sampling rate.
uint32_t buffer_size
Size of the buffer.
Definition: hal_audio.h:313
audio structure
Definition: hal_audio.h:300
hal_audio_status_t hal_audio_set_stream_in_device(hal_audio_device_t device)
Set audio input device.
No audio device is on.
Definition: hal_audio.h:213
A wrong parameter is given.
Definition: hal_audio.h:196
Stream in: earphone mic.
Definition: hal_audio.h:215
Stream out:loudspeaker, mono.
Definition: hal_audio.h:217
11025Hz
Definition: hal_audio.h:245
Audio stream mode structure.
Definition: hal_audio.h:290
Audio playback: music and Record voice.
Definition: hal_audio.h:277
hal_audio_status_t hal_audio_deinit(void)
Deinitialize audio settings.
hal_audio_bits_per_sample_t
Define the number of bits per second (bps) to stream audio data.
Definition: hal_audio.h:257
hal_audio_status_t hal_audio_start_stream_out(hal_audio_active_type_t active_type)
Power on the audio out.
No error occurred during the function call.
Definition: hal_audio.h:198
void hal_audio_stop_stream_in(void)
Power off the stream in path.
void(* hal_audio_stream_in_callback_t)(hal_audio_event_t event, void *user_data)
This defines the audio stream in callback function prototype.
Definition: hal_audio.h:340
24 bps
Definition: hal_audio.h:259
hal_audio_status_t hal_audio_register_copied_stream_out_callback(hal_audio_stream_copy_callback_t callback, void *user_data)
Register the callback function to copy stream out data.
void hal_audio_mute_stream_out(bool mute)
Mute the audio output stream.
void(* hal_audio_stream_copy_callback_t)(hal_audio_event_t event, hal_audio_copy_stream_t *user_data)
This defines the audio stream copy callback function prototype.
Definition: hal_audio.h:348
hal_audio_active_type_t
audio function define
Definition: hal_audio.h:272
Mute line in path.
Definition: hal_audio.h:233
Mute main mic.
Definition: hal_audio.h:228
void hal_audio_mute_stream_in(bool mute)
Mute the audio input stream.
hal_audio_channel_number_t stream_channel
Specifies the number of channel.
Definition: hal_audio.h:293
hal_audio_bits_per_sample_t stream_bit_rate
Specifies the number of bps of audio data.
Definition: hal_audio.h:292
Stream out:earphone, mono to stereo.
Definition: hal_audio.h:220
hal_audio_status_t hal_audio_get_stream_out_sample_count(uint32_t *sample_count)
Query available free space for the output.
hal_audio_status_t hal_audio_get_stream_in_sample_count(uint32_t *sample_count)
Query the available input data sample count.
uint8_t * buffer
Buffer pointer to stream out data.
Definition: hal_audio.h:312
hal_audio_stream_mode_t stream_in
Audio input configuration.
Definition: hal_audio.h:301
No function is disabled.
Definition: hal_audio.h:238
Transmit data underflow.
Definition: hal_audio.h:205
Stream in: single digital mic.
Definition: hal_audio.h:223
8000Hz
Definition: hal_audio.h:244
hal_audio_device_t audio_device
Specifies the device.
Definition: hal_audio.h:294
16000Hz
Definition: hal_audio.h:247
hal_audio_mute_function_t
Define the audio mute function.
Definition: hal_audio.h:237
hal_audio_stream_mode_t stream_out
Audio output configuration.
Definition: hal_audio.h:302
No error occurred during the function call.
Definition: hal_audio.h:204
hal_audio_status_t hal_audio_set_stream_out_sampling_rate(hal_audio_sampling_rate_t sample_rate)
Set the sampling rate of the audio output stream.
hal_audio_event_t
Audio event.
Definition: hal_audio.h:202
hal_audio_status_t hal_audio_set_stream_in_volume(uint32_t digital_volume_index, uint32_t analog_volume_index)
Set audio input volume.
void(* hal_audio_stream_out_callback_t)(hal_audio_event_t event, void *user_data)
This defines the audio stream out callback function prototype.
Definition: hal_audio.h:332
uint32_t analog_gain_index
Analog gain index of the audio stream.
Definition: hal_audio.h:296
PCM playback path is disabled.
Definition: hal_audio.h:239
hal_audio_status_t hal_audio_write_stream_out(const void *buffer, uint32_t size)
Write data to audio output.
Mute reciever.
Definition: hal_audio.h:230
bool loopback
Audio loopback configuration.
Definition: hal_audio.h:305
hal_audio_mute_t
Define the audio mute function.
Definition: hal_audio.h:227
An error occured during the function call.
Definition: hal_audio.h:203
hal_audio_mute_t mute_device
Audio mute devices.
Definition: hal_audio.h:304
Send a user request to provide data.
Definition: hal_audio.h:206
No more audio data from user.
Definition: hal_audio.h:208
hal_audio_status_t hal_audio_register_stream_out_callback(hal_audio_stream_out_callback_t callback, void *user_data)
Register the callback function for output data.
A single channel.
Definition: hal_audio.h:264
Two channels, but only output L channel.
Definition: hal_audio.h:266
hal_audio_active_type_t audio_path_type
Audio function type.
Definition: hal_audio.h:303
Record voice.
Definition: hal_audio.h:275
hal_audio_status_t hal_audio_start_stream_in(hal_audio_active_type_t active_type)
Power on the audio in.
hal_audio_sampling_rate_t
Define audio sampling rate.
Definition: hal_audio.h:243
audio structure
Definition: hal_audio.h:310
Stream in/out: line in.
Definition: hal_audio.h:221
Mute loudspeaker.
Definition: hal_audio.h:231
44100Hz
Definition: hal_audio.h:251
Mute earphone.
Definition: hal_audio.h:232
Two channels, L and R channels are swapped.
Definition: hal_audio.h:268
hal_audio_status_t hal_audio_set_stream_out_volume(uint32_t digital_volume_index, uint32_t analog_volume_index)
Set audio output the volume.
hal_audio_status_t hal_audio_set_stream_out_device(hal_audio_device_t device)
Set the audio output device.
12000Hz
Definition: hal_audio.h:246
96000Hz
Definition: hal_audio.h:253
Turn on both voice stream in and out.
Definition: hal_audio.h:276
hal_audio_status_t hal_audio_init(void)
Initializes basic settings of the audio hardware.
An error occured during the function call.
Definition: hal_audio.h:197
Two channels, but only output R channel.
Definition: hal_audio.h:267
48000Hz
Definition: hal_audio.h:252
Two channels.
Definition: hal_audio.h:265
uint32_t channel
Stream out datat channel.
Definition: hal_audio.h:315