-
Notifications
You must be signed in to change notification settings - Fork 9
/
audio.h
113 lines (83 loc) · 2.91 KB
/
audio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifdef __cplusplus
extern "C" {
#endif
#include "display.h"
#ifdef AWBM_PLATFORM_h3
#define HDMI_AUDIO_IRQ 47 // I2S
#elif defined(AWBM_PLATFORM_h616)
#define HDMI_AUDIO_IRQ 56 // AHUB
#endif
void audio_hdmi_init(void);
void audio_i2s2_init(void);
void audio_i2s2_on(void);
void audio_queue_samples(void);
#ifdef AWBM_PLATFORM_h3
#define I2S_BASE_BASE 0x01c22000
#define I2S_BASE(n) (I2S_BASE_BASE + (n) * 0x400)
#define I2S_REG(n, reg) *(volatile uint32_t*)(I2S_BASE(n) + (reg))
#define I2S_CTL(n) I2S_REG(n, 0x00)
#define I2S_CTL_BCLK_OUT (1 << 18)
#define I2S_CTL_LRCK_OUT (1 << 17)
#define I2S_CTL_LRCKR_OUT (1 << 16)
#define I2S_CTL_SDO0_EN (1 << 8)
#define I2S_CTL_MODE_SEL(n) ((n) << 4)
#define I2S_CTL_TXEN (1 << 2)
#define I2S_CTL_RXEN (1 << 1)
#define I2S_CTL_GEN (1 << 0)
#define I2S_FAT0(n) I2S_REG(n, 0x04)
#define I2S_FAT0_SW(n) ((n) << 0)
#define I2S_FAT0_SR(n) ((n) << 4)
#define I2S_FAT0_LRCK_PERIOD(n) ((n) << 8)
#define I2S_FAT0_LRCKR_PERIOD(n) ((n) << 20)
#define I2S_FAT1(n) I2S_REG(n, 0x08)
#define I2S_FCTL(n) I2S_REG(n, 0x14)
#define I2S_FCTL_TXTL(n) ((n) << 12)
#define I2S_FCTL_RXTL(n) ((n) << 4)
#define I2S_FCTL_TXIM(n) ((n) << 2)
#define I2S_FCTL_RXOM(n) ((n) << 0)
#define I2S_FCTL_FRX (1 << 24)
#define I2S_FCTL_FTX (1 << 25)
#define I2S_FSTA(n) I2S_REG(n, 0x18)
#define I2S_FSTA_TXE (1 << 28)
#define I2S_TXFIFO(n) I2S_REG(n, 0x20)
#define I2S_INT(n) I2S_REG(n, 0x1c)
#define I2S_INT_TXEI_EN (1 << 4)
#define I2S_CLKD(n) I2S_REG(n, 0x24)
#define I2S_CLKD_MCLKDIV(n) ((n) << 0)
#define I2S_CLKD_BCLKDIV(n) ((n) << 4)
#define I2S_CLKD_MCLKO_EN (1 << 8)
#define I2S_TXCNT(n) I2S_REG(n, 0x28)
#define I2S_RXCNT(n) I2S_REG(n, 0x2c)
#define I2S_TXCHCFG_H3(n) I2S_REG(n, 0x30)
#define I2S_CHCFG_RX_SLOT_NUM(n) ((n) << 4)
#define I2S_CHCFG_TX_SLOT_NUM(n) ((n) << 0)
#define I2S_TX0CHSEL_H3(n) I2S_REG(n, 0x34)
#define I2S_TXnCHSEL_OFFSET_1 (1 << 12)
#define I2S_TXnCHSEL_CHSEL_2 (1 << 0)
#define I2S_TXnCHSEL_CHEN_0 (1 << 4)
#define I2S_TXnCHSEL_CHEN_1 (1 << 5)
#define I2S_TX0CHMAP_H3(n) I2S_REG(n, 0x44)
#define I2S_TXnCHMAP_CH0_SAMPLE(n) ((n) << 0)
#define I2S_TXnCHMAP_CH1_SAMPLE(n) ((n) << 4)
#define I2S_RXCHSEL(n) I2S_REG(n, 0x54)
#define I2S_RXCHSEL_OFFSET(n) ((n) << 12)
#define I2S_RXCHSEL_CHSEL(n) ((n) << 0)
#define I2S_RXCHMAP(n) I2S_REG(n, 0x58)
#define I2S_RXCHMAP_CH_SAMPLE(ch, n) ((n) << ((ch) * 4))
#endif
#ifdef AWBM_PLATFORM_h616
#define AHUB_BASE_BASE 0x5097000
#define AHUB_BASE(n) (AHUB_BASE_BASE + (n) * 0x30)
#define AHUB_I2S_BASE(n) (AHUB_BASE_BASE + (n) * 0x100)
#define AHUB_DAM_BASE(n) (AHUB_BASE_BASE + (n) * 0x80)
#define AHUB_APBIF_TXIRQ_CTRL(n) MEM(AHUB_BASE(n) + 0x14)
#define AHUB_APBIF_TXFIFO_STS(n) MEM(AHUB_BASE(n) + 0x24)
#define AHUB_APBIF_TXFIFO(n) MEM(AHUB_BASE(n) + 0x30)
#define AC_BASE 0x5096000
#define AC_DAC_TXDATA MEM(AC_BASE + 0x20)
#endif
void hook_audio_get_sample(int16_t *l, int16_t *r);
void audio_start(int buf_len);
#ifdef __cplusplus
}
#endif