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 {
209 
211 typedef enum {
224 
226 typedef enum {
234 
236 typedef enum {
240 
242 typedef enum {
254 
256 typedef enum {
260 
262 typedef enum {
268 
270 typedef enum {
277 
278 
288 typedef struct {
294  uint32_t analog_gain_index;
296 
298 typedef struct {
303  bool loopback;
305 
306 
321 typedef void (*hal_audio_stream_out_callback_t)(hal_audio_event_t event, void *user_data);
322 
329 typedef void (*hal_audio_stream_in_callback_t)(hal_audio_event_t event, void *user_data);
330 
342 
349 
358 
365 
373 
378 void hal_audio_stop_stream_out(void);
379 
386 hal_audio_status_t hal_audio_set_stream_out_volume(uint32_t digital_volume_index, uint32_t analog_volume_index);
387 
395 void hal_audio_mute_stream_out(bool mute);
396 
403 
411 hal_audio_status_t hal_audio_write_stream_out(const void *buffer, uint32_t size);
412 
421 
429 
440 
450 
461 
469 void hal_audio_stop_stream_in(void);
470 
477 hal_audio_status_t hal_audio_set_stream_in_volume(uint32_t digital_volume_index, uint32_t analog_volume_index);
478 
486 void hal_audio_mute_stream_in(bool mute);
487 
497 
505 hal_audio_status_t hal_audio_read_stream_in(void *buffer, uint32_t sample_count);
506 
515 
526 
534 hal_audio_status_t hal_audio_get_memory_size(uint32_t *memory_size);
535 
544 
551 hal_audio_status_t hal_audio_get_audio_clock(uint32_t *sample_count);
552 
553 #ifdef __cplusplus
554 }
555 #endif
556 
561 #endif /*HAL_AUDIO_MODULE_ENABLED*/
562 #endif /*__HAL_AUDIO_H__*/
24000Hz
Definition: hal_audio.h:248
22050Hz
Definition: hal_audio.h:247
Stream in: dual digital mic.
Definition: hal_audio.h:221
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.
Audio playback: music.
Definition: hal_audio.h:271
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:217
32000Hz
Definition: hal_audio.h:249
hal_audio_status_t
Audio status.
Definition: hal_audio.h:195
Voice playback: voice.
Definition: hal_audio.h:272
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:215
Stream out:earphone, stereo.
Definition: hal_audio.h:218
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:262
void hal_audio_stop_stream_out(void)
Power off the stream out path.
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:213
uint32_t digital_gain_index
Digital gain index of the audio stream.
Definition: hal_audio.h:293
hal_audio_sampling_rate_t stream_sampling_rate
Specifies the sampling rate of audio data.
Definition: hal_audio.h:289
16 bps
Definition: hal_audio.h:257
Mute earphone mic.
Definition: hal_audio.h:228
hal_audio_device_t
Audio device.
Definition: hal_audio.h:211
hal_audio_status_t hal_audio_set_stream_in_sampling_rate(hal_audio_sampling_rate_t sample_rate)
Set audio input stream sampling rate.
audio structure
Definition: hal_audio.h:298
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:212
A wrong parameter is given.
Definition: hal_audio.h:196
Stream in: earphone mic.
Definition: hal_audio.h:214
Stream out:loudspeaker, mono.
Definition: hal_audio.h:216
11025Hz
Definition: hal_audio.h:244
Audio stream mode structure.
Definition: hal_audio.h:288
Audio playback: music and Record voice.
Definition: hal_audio.h:275
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:256
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:329
24 bps
Definition: hal_audio.h:258
void hal_audio_mute_stream_out(bool mute)
Mute the audio output stream.
hal_audio_active_type_t
audio function define
Definition: hal_audio.h:270
Mute line in path.
Definition: hal_audio.h:232
Mute main mic.
Definition: hal_audio.h:227
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:291
hal_audio_bits_per_sample_t stream_bit_rate
Specifies the number of bps of audio data.
Definition: hal_audio.h:290
Stream out:earphone, mono to stereo.
Definition: hal_audio.h:219
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.
hal_audio_stream_mode_t stream_in
Audio input configuration.
Definition: hal_audio.h:299
No function is disabled.
Definition: hal_audio.h:237
Transmit data underflow.
Definition: hal_audio.h:205
Stream in: single digital mic.
Definition: hal_audio.h:222
8000Hz
Definition: hal_audio.h:243
hal_audio_device_t audio_device
Specifies the device.
Definition: hal_audio.h:292
16000Hz
Definition: hal_audio.h:246
hal_audio_mute_function_t
Define the audio mute function.
Definition: hal_audio.h:236
hal_audio_stream_mode_t stream_out
Audio output configuration.
Definition: hal_audio.h:300
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:321
uint32_t analog_gain_index
Analog gain index of the audio stream.
Definition: hal_audio.h:294
PCM playback path is disabled.
Definition: hal_audio.h:238
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:229
bool loopback
Audio loopback configuration.
Definition: hal_audio.h:303
hal_audio_mute_t
Define the audio mute function.
Definition: hal_audio.h:226
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:302
Send a user request to provide data.
Definition: hal_audio.h:206
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:263
Two channels but only output L channel.
Definition: hal_audio.h:265
hal_audio_active_type_t audio_path_type
Audio function type.
Definition: hal_audio.h:301
Record voice.
Definition: hal_audio.h:273
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:242
Stream in/out: line in.
Definition: hal_audio.h:220
Mute loudspeaker.
Definition: hal_audio.h:230
44100Hz
Definition: hal_audio.h:250
Mute earphone.
Definition: hal_audio.h:231
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:245
96000Hz
Definition: hal_audio.h:252
Turn on both voice stream in and out.
Definition: hal_audio.h:274
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:266
48000Hz
Definition: hal_audio.h:251
Two channels.
Definition: hal_audio.h:264