MT7687 API Reference  LinkIt SDK v4
hal_i2s.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_I2S_H__
36 #define __HAL_I2S_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_I2S_MODULE_ENABLED
41 #ifdef HAL_I2S_SUPPORT_VFIFO
42 
338 #else
339 
614 #endif // #ifdef HAL_I2S_SUPPORT_VFIFO
615 
616 
617 #ifdef __cplusplus
618 extern "C" {
619 #endif
620 
621 
627 typedef enum {
632 
633 
635 typedef enum {
639 
640 
642 typedef enum {
646 
647 
658 typedef struct {
661 #ifdef HAL_I2S_EXTENDED
662  uint32_t msb_offset;
666 #endif
668 
669 
671 typedef struct {
675 #ifdef HAL_I2S_FEATURE_TDM
676  hal_i2s_tdm_channel_t tdm_channel;
677 #endif
678 #ifdef HAL_I2S_EXTENDED
679  hal_i2s_frame_sync_width_t frame_sync_width;
684 #endif
686 
687 
697 #ifdef HAL_I2S_SUPPORT_VFIFO
698 
704 #else
705 
711 #endif
712 typedef void (*hal_i2s_rx_callback_t)(hal_i2s_event_t event, void *user_data);
713 
714 
715 #ifdef HAL_I2S_SUPPORT_VFIFO
716 
722 #else
723 
729 #endif
730 typedef void (*hal_i2s_tx_callback_t)(hal_i2s_event_t event, void *user_data);
731 
732 
733 
749 #ifdef HAL_I2S_FEATURE_MULTI_I2S
750 
761 hal_i2s_status_t hal_i2s_init_ex(hal_i2s_port_t i2s_port, hal_i2s_initial_type_t i2s_initial_type);
762 #endif
763 
764 
772 #ifdef HAL_I2S_FEATURE_MULTI_I2S
773 
781 hal_i2s_status_t hal_i2s_deinit_ex(hal_i2s_port_t i2s_port);
782 #endif
783 
784 
796 #ifdef HAL_I2S_FEATURE_MULTI_I2S
797 
808 hal_i2s_status_t hal_i2s_set_config_ex(hal_i2s_port_t i2s_port, const hal_i2s_config_t *config);
809 #endif
810 
811 
820 #ifdef HAL_I2S_FEATURE_MULTI_I2S
821 
829 hal_i2s_status_t hal_i2s_get_config_ex(hal_i2s_port_t i2s_port, hal_i2s_config_t *config);
830 #endif
831 
832 
833 #ifdef HAL_I2S_SUPPORT_VFIFO
834 
842 #ifdef HAL_I2S_FEATURE_MULTI_I2S
843 
851 hal_i2s_status_t hal_i2s_enable_audio_top_ex(hal_i2s_port_t i2s_port);
852 #endif
853 
854 
862 #ifdef HAL_I2S_FEATURE_MULTI_I2S
863 
870 hal_i2s_status_t hal_i2s_disable_audio_top_ex(hal_i2s_port_t i2s_port);
871 #endif
872 
873 
874 #else
875 
883 hal_i2s_status_t hal_i2s_get_memory_size(uint32_t *memory_size);
884 
885 
894 hal_i2s_status_t hal_i2s_set_memory(uint8_t *memory);
895 
896 
904 hal_i2s_status_t hal_i2s_get_memory_pointer(uint8_t **memory_pointer);
905 #endif
906 
907 
908 #ifdef HAL_I2S_SUPPORT_VFIFO
909 
918 #ifdef HAL_I2S_FEATURE_MULTI_I2S
919 
927 hal_i2s_status_t hal_i2s_enable_tx_dma_interrupt_ex(hal_i2s_port_t i2s_port);
928 #endif
929 
930 
938 #ifdef HAL_I2S_FEATURE_MULTI_I2S
939 
946 hal_i2s_status_t hal_i2s_disable_tx_dma_interrupt_ex(hal_i2s_port_t i2s_port);
947 #endif
948 
949 
958 #ifdef HAL_I2S_FEATURE_MULTI_I2S
959 
967 hal_i2s_status_t hal_i2s_enable_rx_dma_interrupt_ex(hal_i2s_port_t i2s_port);
968 #endif
969 
970 
978 #ifdef HAL_I2S_FEATURE_MULTI_I2S
979 
986 hal_i2s_status_t hal_i2s_disable_rx_dma_interrupt_ex(hal_i2s_port_t i2s_port);
987 #endif
988 
989 
1004 hal_i2s_status_t hal_i2s_setup_tx_vfifo(uint32_t *buffer, uint32_t threshold, uint32_t buffer_length);
1005 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1006 
1021 hal_i2s_status_t hal_i2s_setup_tx_vfifo_ex(hal_i2s_port_t i2s_port, uint32_t *buffer, uint32_t threshold, uint32_t buffer_length);
1022 #endif
1023 
1024 
1033 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1034 
1042 hal_i2s_status_t hal_i2s_stop_tx_vfifo_ex(hal_i2s_port_t i2s_port);
1043 #endif
1044 
1045 
1060 hal_i2s_status_t hal_i2s_setup_rx_vfifo(uint32_t *buffer, uint32_t threshold, uint32_t buffer_length);
1061 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1062 
1077 hal_i2s_status_t hal_i2s_setup_rx_vfifo_ex(hal_i2s_port_t i2s_port, uint32_t *buffer, uint32_t threshold, uint32_t buffer_length);
1078 #endif
1079 
1080 
1089 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1090 
1098 hal_i2s_status_t hal_i2s_stop_rx_vfifo_ex(hal_i2s_port_t i2s_port);
1099 #endif
1100 
1101 #endif
1102 
1103 
1104 #ifdef HAL_I2S_SUPPORT_VFIFO
1105 
1114 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1115 
1124 hal_i2s_status_t hal_i2s_register_rx_vfifo_callback_ex(hal_i2s_port_t i2s_port, hal_i2s_rx_callback_t rx_callback, void *user_data);
1125 #endif
1126 #else
1127 
1135 hal_i2s_status_t hal_i2s_register_rx_callback(hal_i2s_rx_callback_t rx_callback, void *user_data);
1136 #endif
1137 
1138 
1139 #ifdef HAL_I2S_SUPPORT_VFIFO
1140 
1149 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1150 
1159 hal_i2s_status_t hal_i2s_register_tx_vfifo_callback_ex(hal_i2s_port_t i2s_port, hal_i2s_tx_callback_t tx_callback, void *user_data);
1160 #endif
1161 #else
1162 
1170 hal_i2s_status_t hal_i2s_register_tx_callback(hal_i2s_tx_callback_t tx_callback, void *user_data);
1171 #endif
1172 
1173 
1174 #ifdef HAL_I2S_SUPPORT_VFIFO
1175 
1182 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1183 
1190 hal_i2s_status_t hal_i2s_enable_tx_ex(hal_i2s_port_t i2s_port);
1191 #endif
1192 #else
1193 
1200 #endif
1201 
1202 
1210 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1211 
1218 hal_i2s_status_t hal_i2s_disable_tx_ex(hal_i2s_port_t i2s_port);
1219 #endif
1220 
1221 
1222 #ifdef HAL_I2S_SUPPORT_VFIFO
1223 
1232 hal_i2s_status_t hal_i2s_tx_write(uint32_t data);
1233 
1234 
1235 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1236 
1246 hal_i2s_status_t hal_i2s_tx_write_ex(hal_i2s_port_t i2s_port, uint32_t data);
1247 #endif
1248 
1249 #else
1250 
1260 hal_i2s_status_t hal_i2s_tx_write(const void *buffer, uint32_t sample_count);
1261 #endif
1262 
1263 
1264 #ifdef HAL_I2S_SUPPORT_VFIFO
1265 
1273  hal_i2s_status_t hal_i2s_get_tx_sample_count(uint32_t *sample_count);
1274 
1275 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1276 
1285  hal_i2s_status_t hal_i2s_get_tx_sample_count_ex(hal_i2s_port_t i2s_port, uint32_t *sample_count);
1286 #endif
1287 #else
1288 
1296  hal_i2s_status_t hal_i2s_get_tx_sample_count(uint32_t *sample_count);
1297 #endif
1298 
1299 
1300 #ifdef HAL_I2S_SUPPORT_VFIFO
1301 
1308 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1309 
1316 hal_i2s_status_t hal_i2s_enable_rx_ex(hal_i2s_port_t i2s_port);
1317 #endif
1318 #else
1319 
1327 #endif
1328 
1329 
1337 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1338 
1345 hal_i2s_status_t hal_i2s_disable_rx_ex(hal_i2s_port_t i2s_port);
1346 #endif
1347 
1348 
1349 #ifdef HAL_I2S_SUPPORT_VFIFO
1350 
1358 hal_i2s_status_t hal_i2s_rx_read(uint32_t *data);
1359 
1360 
1361 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1362 
1370 hal_i2s_status_t hal_i2s_rx_read_ex(hal_i2s_port_t i2s_port, uint32_t *data);
1371 #endif
1372 
1373 #else
1374 
1384 hal_i2s_status_t hal_i2s_rx_read(void *buffer, uint32_t sample_count);
1385 #endif
1386 
1387 
1388 #ifdef HAL_I2S_SUPPORT_VFIFO
1389 
1397 hal_i2s_status_t hal_i2s_get_rx_sample_count(uint32_t *sample_count);
1398 
1399 #ifdef HAL_I2S_FEATURE_MULTI_I2S
1400 
1409 hal_i2s_status_t hal_i2s_get_rx_sample_count_ex(hal_i2s_port_t i2s_port, uint32_t *sample_count);
1410 #endif
1411 
1412 #else
1413 
1421 hal_i2s_status_t hal_i2s_get_rx_sample_count(uint32_t *sample_count);
1422 #endif
1423 
1424 
1425 #ifdef __cplusplus
1426 }
1427 #endif
1428 
1429 
1434 #endif /*HAL_I2S_MODULE_ENABLED*/
1435 #endif /* __HAL_I2S_H__ */
1436 
hal_i2s_sample_rate_t
I2S sample rate definition.
Definition: hal_platform.h:352
hal_i2s_status_t hal_i2s_init(hal_i2s_initial_type_t i2s_initial_type)
This function initializes the I2S hardware type.
hal_i2s_status_t hal_i2s_setup_rx_vfifo(uint32_t *buffer, uint32_t threshold, uint32_t buffer_length)
This function sets up the receive operation.
hal_i2s_status_t hal_i2s_get_rx_sample_count(uint32_t *sample_count)
This function queries length of the received data available in the RX VFIFO.
hal_i2s_sample_width_t sample_width
<Width per frame sync.
Definition: hal_i2s.h:680
hal_i2s_sample_width_t
I2S sample widths.
Definition: hal_platform.h:362
hal_i2s_status_t hal_i2s_rx_read(uint32_t *data)
This function receives data from the I2S input link.
An error occurred during the function call.
Definition: hal_i2s.h:629
hal_i2s_word_select_inverse_t
Enable or disable word select clock inverting of the I2S link.
Definition: hal_platform.h:395
Two channels.
Definition: hal_i2s.h:644
Clock source fed to an external device.
Definition: hal_i2s.h:636
Clock source comes from an external device.
Definition: hal_i2s.h:637
hal_i2s_channel_number_t
This enum defines the I2S channel number.
Definition: hal_i2s.h:642
hal_i2s_clock_mode_t
This enum defines the I2S clock mode.
Definition: hal_i2s.h:635
hal_i2s_tx_mode_t
Enable or disable right channel of the I2S TX to send the same data as on the left channel of the I2S...
Definition: hal_platform.h:376
hal_i2s_status_t hal_i2s_disable_audio_top(void)
This function disables uplink and downlink FIFOs of the I2S link.
hal_i2s_status_t hal_i2s_register_tx_vfifo_callback(hal_i2s_tx_callback_t tx_callback, void *user_data)
This function registers the callback function for output data.
hal_i2s_link_config_t i2s_in
I2S input link configuration.
Definition: hal_i2s.h:672
hal_i2s_event_t
I2S event.
Definition: hal_platform.h:346
hal_i2s_status_t hal_i2s_disable_tx_dma_interrupt(void)
This function disables the TX VFIFO DMA interrupt.
hal_i2s_tx_mode_t tx_mode
Enable or disable the I2S TX to send the same data on right and left channels.
Definition: hal_i2s.h:681
hal_i2s_status_t hal_i2s_enable_rx(void)
This function enables the I2S input link.
hal_i2s_status_t hal_i2s_tx_write(uint32_t data)
This function transmits data to the I2S output link.
hal_i2s_clock_mode_t clock_mode
I2S clock source.
Definition: hal_i2s.h:674
hal_i2s_status_t hal_i2s_get_tx_sample_count(uint32_t *sample_count)
This function queries available free space in the TX VFIFO.
hal_i2s_link_config_t i2s_out
I2S output link configuration.
Definition: hal_i2s.h:673
No error occurred during the function call.
Definition: hal_i2s.h:630
hal_i2s_rx_down_rate_t
Enable or disable twice the downsampling rate mode in the I2S RX link.
Definition: hal_platform.h:383
hal_i2s_status_t hal_i2s_enable_tx(void)
This function enables the I2S output link.
hal_i2s_status_t hal_i2s_enable_tx_dma_interrupt(void)
This function enables the TX VFIFO DMA interrupt.
hal_i2s_status_t hal_i2s_disable_tx(void)
This function disables the I2S output link.
hal_i2s_status_t
This enum defines the I2S status.
Definition: hal_i2s.h:627
hal_i2s_status_t hal_i2s_get_config(hal_i2s_config_t *config)
This function queries the I2S configuration details.
hal_i2s_lr_swap_t
Enable or disable data swapping between right and left channels of the I2S link.
Definition: hal_platform.h:389
hal_i2s_status_t hal_i2s_register_rx_vfifo_callback(hal_i2s_rx_callback_t rx_callback, void *user_data)
This function registers the callback function for input data.
hal_i2s_frame_sync_width_t
Number of bits per frame sync(FS).
Definition: hal_platform.h:369
hal_i2s_status_t hal_i2s_stop_tx_vfifo(void)
This function stops the transmit operation.
hal_i2s_status_t hal_i2s_set_config(const hal_i2s_config_t *config)
This function sets the I2S configuration details.
hal_i2s_status_t hal_i2s_enable_audio_top(void)
This function enables uplink and downlink FIFOs of the I2S link.
A wrong parameter is given.
Definition: hal_i2s.h:628
void(* hal_i2s_rx_callback_t)(hal_i2s_event_t event, void *user_data)
This function defines the I2S RX VFIFO callback function prototype.
Definition: hal_i2s.h:712
void(* hal_i2s_tx_callback_t)(hal_i2s_event_t event, void *user_data)
This function defines the I2S TX VFIFO callback function prototype.
Definition: hal_i2s.h:730
I2S configure structure.
Definition: hal_i2s.h:671
hal_i2s_status_t hal_i2s_stop_rx_vfifo(void)
This function stops the receive operation.
hal_i2s_status_t hal_i2s_deinit(void)
This function deinitializes the I2S hardware.
hal_i2s_status_t hal_i2s_disable_rx_dma_interrupt(void)
This function disables the RX VFIFO DMA interrupt.
hal_i2s_status_t hal_i2s_disable_rx(void)
This function disables the I2S input link.
hal_i2s_status_t hal_i2s_setup_tx_vfifo(uint32_t *buffer, uint32_t threshold, uint32_t buffer_length)
This function sets up the transmit operation.
A single channel.
Definition: hal_i2s.h:643
hal_i2s_status_t hal_i2s_enable_rx_dma_interrupt(void)
This function enables the RX VFIFO DMA interrupt.
hal_i2s_initial_type_t
This enum defines initial type of I2S.
Definition: hal_platform.h:338
hal_i2s_rx_down_rate_t rx_down_rate
Enable or disable downsampling of the I2S RX rate by half of the I2S RX sampling rate by automaticall...
Definition: hal_i2s.h:683