1 #ifndef _AUDIO_RL6548_H 2 #define _AUDIO_RL6548_H 3 4 #include "ameba_soc.h" 5 #include "rl6548.h" 6 7 #define SP_DMA_PAGE_SIZE 1600 8 #define SP_DMA_PAGE_NUM 4 9 #define SP_FULL_BUF_SIZE 128 10 #define SP_ZERO_BUF_SIZE 128 11 12 #define SET_VOLUME CODEC_SetVolume 13 #define GET_VOLUME CODEC_GetVolume 14 #define VOLUME_MAX (0xAF) 15 #define VOLUME_MIX (0x00) 16 17 //#define ENABLE_PA 18 typedef struct { 19 GDMA_InitTypeDef SpTxGdmaInitStruct; //Pointer to GDA_InitTypeDef 20 GDMA_InitTypeDef SpRxGdmaInitStruct; //Pointer to GDA_InitTypeDef 21 }SP_GDMA_STRUCT, *pSP_GDMA_STRUCT; 22 23 typedef struct { 24 u8 rx_gdma_own; 25 u32 rx_addr; 26 u32 rx_length; 27 28 }RX_BLOCK, *pRX_BLOCK; 29 30 typedef struct { 31 RX_BLOCK rx_block[SP_DMA_PAGE_NUM]; 32 RX_BLOCK rx_full_block; 33 u8 rx_gdma_cnt; 34 u8 rx_usr_cnt; 35 u8 rx_full_flag; 36 37 }SP_RX_INFO, *pSP_RX_INFO; 38 39 typedef struct { 40 u8 tx_gdma_own; 41 u32 tx_addr; 42 u32 tx_length; 43 }TX_BLOCK, *pTX_BLOCK; 44 45 typedef struct { 46 TX_BLOCK tx_block[SP_DMA_PAGE_NUM]; 47 TX_BLOCK tx_zero_block; 48 u8 tx_gdma_cnt; 49 u8 tx_usr_cnt; 50 u8 tx_empty_flag; 51 52 }SP_TX_INFO, *pSP_TX_INFO; 53 54 typedef struct { 55 u32 sample_rate; 56 u32 word_len; 57 u32 mono_stereo; 58 u32 direction; 59 }SP_OBJ, *pSP_OBJ; 60 61 62 void *rl6548_audio_init(int sampleRate, int channels, int wordLen); 63 void rl6548_audio_deinit(); 64 65 void rl6548_capture_start(); 66 void rl6548_playback_start(); 67 void rl6548_capture_stop(); 68 void rl6548_playback_stop(); 69 70 int rl6548_audio_write(void *h, uint8_t *buf, uint32_t size); 71 int rl6548_data_read(void *handle, void *buf, unsigned int size); 72 73 74 int rl6548_volume_get(); 75 void rl6548_volume_set(int index); 76 int rl6548_get_mute(); 77 void rl6548_set_mute(int mute); 78 79 #endif 80