api_dac.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _API_DAC_H_
  2. #define _API_DAC_H_
  3. #define PCM_OUT_24BITS BIT(0)
  4. #define PCM_OUT_MONO BIT(1)
  5. void adpll_init(u8 out48k_spr);
  6. void adpll_spr_set(u8 out48k_spr);
  7. //dac
  8. void dac_cb_init(u32 dac_cfg);
  9. void dac_power_on(void);
  10. void dac_restart(void);
  11. void dac_power_off(void);
  12. bool dac_get_pwr_sta(void);
  13. void dac_mono_init(bool dual_en, bool lr_sel); //when dual_en=1, select select left and right mixed
  14. // lr_sel is invalid
  15. //when dual_en=0, lr_sel=1 select left channel
  16. // lr_sel=0 select right channel
  17. void dac_channel_enable(void); //enable dac output channel
  18. void dac_channel_disable(void); //disable dac output channel, for power save
  19. void dac_balance_set(u16 l_vol, u16 r_vol); //left & right volume balance(0~0x7fff)
  20. void dac_ang_gain_set(u8 gain);
  21. void dac_clk_source_sel(u32 val);
  22. void dac_fade_process(void);
  23. void dac_unmute_set_delay(u16 delay);
  24. void dac_fifo_detect(void);
  25. u32 dac_pcm_pow_calc(void);
  26. void dac_dump_vol(void); //dump all volume regs, for debug
  27. void dac_src_vol_set(uint src_idx, u32 vol);
  28. bool dac_src_fade_in(uint src_idx, uint fade_step);
  29. bool dac_src_fade_out(uint src_idx, uint fade_step);
  30. void dac_src_fade_wait(uint8_t src_idx);
  31. void dac_src_w4_empty(int src_idx);
  32. bool aubuf_dma_is_busy(u8 index);
  33. //dac0
  34. #define dac_vol_set(vol) dac_src_vol_set(0, vol) //dac0 set volume(0~0x7fff)
  35. #define dac_fade_out() dac_src_fade_out(0, 2) //dac0 fade out
  36. #define dac_fade_in() dac_src_fade_in(0, 2) //dac0 fade in
  37. #define dac_fade_wait() dac_src_fade_wait(0) //dac0 fade wait
  38. bool dac_is_fade_in(void); //dac0 get fade in state
  39. void dac_vol_set_reduce(u16 percent);
  40. void dac_spr_set(uint spr); //dac0 set sample rate
  41. u8 dac_spr_get(void); //dac0 get sample rate
  42. void dac_aubuf_init(void); //dac0 aubuf init
  43. void dac_aubuf_clr(void); //dac0 clear aubuf
  44. void dac_put_zero(uint samples); //dac0 put some samples to aubuf, value is zero
  45. void dac_put_sample_16bit(s16 left, s16 right); //dac0 put one sample(16bit) to aubuf, value is left & right
  46. void dac_put_sample_24bit(s32 left, s32 right); //dac0 put one sample(24bit) to aubuf, value is left & right
  47. void dac_put_sample_16bit_w(s16 left, s16 right); //dac0 put one sample(16bit) to aubuf, wait if aubuf is full
  48. void dac_put_sample_24bit_w(u32 left, u32 right); //dac0 put one sample(16bit) to aubuf, wait if aubuf is full
  49. void aubuf0_dma_init(void);
  50. void aubuf0_dma_exit(void);
  51. void aubuf0_dma_kick(void *ptr, u32 samples, uint nch, bool is_24bit);
  52. void aubuf0_dma_w4_done(void);
  53. //dac1(dac1混合到dac0输出,可独立控制音量)
  54. #define dac1_vol_set(vol) dac_src_vol_set(1, vol) //dac1 set volume(0~0x7fff)
  55. #define dac1_fade_out() dac_src_fade_out(1, 4) //dac1 fade out
  56. #define dac1_fade_in() dac_src_fade_in(1, 4) //dac1 fade in
  57. #define dac1_fade_wait() dac_src_fade_wait(1) //dac1 fade wait
  58. #define dac1_aubuf_w4_empty() dac_src_w4_empty(1)
  59. void dac1_spr_set(uint spr); //dac1 set sample rate
  60. void dac1_aubuf_init(void); //dac1 aubuf init
  61. void dac1_aubuf_clr(void); //dac1 clear aubuf
  62. void dac1_put_zero(uint samples); //dac1 put some samples to aubuf, value is zero
  63. void dac1_put_sample_16bit(s16 left, s16 right); //dac1 put one sample(16bit) to aubuf, value is left & right
  64. void dac1_put_sample_24bit(s32 left, s32 right); //dac1 put one sample(24bit) to aubuf, value is left & right
  65. void aubuf1_dma_init(void);
  66. void aubuf1_dma_exit(void);
  67. void aubuf1_dma_kick(void *ptr, u32 samples, uint nch, bool is_24bit);
  68. void aubuf1_dma_w4_done(void);
  69. #define aubuf1_dma_is_busy() aubuf_dma_is_busy(1)
  70. //dnc
  71. void dac_dnc_init(void);
  72. void dac_dnc_start(void);
  73. void dac_dnc_stop(void);
  74. #endif