1 /*
2  * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3  */
4 #ifndef __HAL_SPDIF_H__
5 #define __HAL_SPDIF_H__
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #ifdef CHIP_HAS_SPDIF
12 
13 #include "plat_types.h"
14 #include "hal_cmu.h"
15 #include "hal_aud.h"
16 
17 struct HAL_SPDIF_CONFIG_T {
18     uint32_t bits;
19     uint32_t channel_num;
20     uint32_t sample_rate;
21 
22     uint32_t use_dma;
23 };
24 
25 int hal_spdif_open(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream);
26 int hal_spdif_close(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream);
27 int hal_spdif_start_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream);
28 int hal_spdif_stop_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream);
29 int hal_spdif_setup_stream(enum HAL_SPDIF_ID_T id, enum AUD_STREAM_T stream, struct HAL_SPDIF_CONFIG_T *cfg);
30 int hal_spdif_send(enum HAL_SPDIF_ID_T id, uint8_t *value, uint32_t value_len);
31 uint8_t hal_spdif_recv(enum HAL_SPDIF_ID_T id, uint8_t *value, uint32_t value_len);
32 
33 int hal_spdif_clock_out_enable(enum HAL_SPDIF_ID_T id, uint32_t div);
34 int hal_spdif_clock_out_disable(enum HAL_SPDIF_ID_T id);
35 
36 #endif // CHIP_HAS_SPDIF
37 
38 #ifdef __cplusplus
39 }
40 #endif
41 
42 #endif
43