• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 iSoftStone Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef T507_CODEC_IMPL_LINUX_H
10 #define T507_CODEC_IMPL_LINUX_H
11 
12 #include "audio_codec_if.h"
13 #include "securec.h"
14 #include "audio_control.h"
15 #include "audio_parse.h"
16 #include "osal_mem.h"
17 #include "osal_time.h"
18 
19 #ifdef __cplusplus
20 #if __cplusplus
21 extern "C" {
22 #endif
23 #endif /* __cplusplus */
24 
25 #define SUNXI_DAC_DPC       0x00
26 #define SUNXI_DAC_FIFO_CTL  0x10
27 #define SUNXI_DAC_FIFO_STA  0x14
28 
29 /* left blank */
30 #define SUNXI_DAC_TXDATA    0X20
31 #define SUNXI_DAC_CNT       0x24
32 #define SUNXI_DAC_DG_REG    0x28
33 
34 #define SUNXI_ADC_FIFO_CTL  0x30
35 #define SUNXI_ADC_FIFO_STA  0x34
36 #define SUNXI_ADC_RXDATA    0x40
37 #define SUNXI_ADC_CNT       0x44
38 #define SUNXI_ADC_DG_REG    0x4C
39 
40 /*left blank */
41 #define SUNXI_DAC_DAP_CTL   0xf0
42 #define SUNXI_ADC_DAP_CTL   0xf8
43 
44 /* DAC */
45 #define AC_DAC_REG          0x310
46 #define AC_MIXER_REG        0x314
47 #define AC_RAMP_REG         0x31c
48 #define SUNXI_AUDIO_MAX_REG AC_RAMP_REG
49 
50 /* SUNXI_DAC_DPC:0x00 */
51 #define EN_DA               31
52 #define MODQU               25
53 #define DWA_EN              24
54 #define HPF_EN              18
55 #define DVOL                12
56 #define DAC_HUB_EN          0
57 
58 /* SUNXI_DAC_FIFO_CTL:0x10 */
59 #define DAC_FS              29
60 #define FIR_VER             28
61 #define SEND_LASAT          26
62 #define DAC_FIFO_MODE       24
63 #define DAC_DRQ_CLR_CNT     21
64 #define TX_TRIG_LEVEL       8
65 #define DAC_MONO_EN         6
66 #define TX_SAMPLE_BITS      5
67 #define DAC_DRQ_EN          4
68 #define DAC_IRQ_EN          3
69 #define DAC_FIFO_UNDERRUN_IRQ_EN    2
70 #define DAC_FIFO_OVERRUN_IRQ_EN     1
71 #define DAC_FIFO_FLUSH      0
72 
73 /* SUNXI_DAC_FIFO_STA:0x14 */
74 #define DAC_TX_EMPTY        23
75 #define DAC_TXE_CNT         8
76 #define DAC_TXE_INT         3
77 #define DAC_TXU_INT         2
78 #define DAC_TXO_INT         1
79 
80 /* SUNXI_DAC_DG_REG:0x28 */
81 #define DAC_MODU_SELECT     11
82 #define DAC_PATTERN_SEL     9
83 #define CODEC_CLK_SEL       8
84 #define DA_SWP              6
85 #define ADDA_LOOP_MODE      0
86 
87 /* SUNXI_ADC_FIFO_CTL:0x30 */
88 #define ADC_FS              29
89 #define EN_AD               28
90 #define ADCFDT              26
91 #define ADCDFEN             25
92 #define RX_FIFO_MODE        24
93 #define RX_SAMPLE_BITS      16
94 #define ADCY_EN             15
95 #define ADCX_EN             14
96 #define ADCR_EN             13
97 #define ADCL_EN             12
98 #define ADC_CHAN_SEL        12
99 #define RX_FIFO_TRG_LEVEL   4
100 #define ADC_DRQ_EN          3
101 #define ADC_IRQ_EN          2
102 #define ADC_OVERRUN_IRQ_EN  1
103 #define ADC_FIFO_FLUSH      0
104 
105 /* SUNXI_ADC_FIFO_STA:0x38 */
106 #define ADC_RXA             23
107 #define ADC_RXA_CNT         8
108 #define ADC_RXA_INT         3
109 #define ADC_RXO_INT         1
110 
111 /* SUNXI_ADC_DG_REG:0x4c */
112 #define ADXY_SWP            25
113 #define ADLR_SWP            24
114 
115 /* DAC */
116 /* AC_DAC_REG */
117 #define CURRENT_TEST_SEL    23
118 #define IOPVRS              20
119 #define ILINEOUTAMPS        18
120 #define IOPDACS             16
121 #define DACLEN              15
122 #define DACREN              14
123 #define LINEOUTL_EN         13
124 #define LMUTE               12
125 #define LINEOUTR_EN         11
126 #define RMUTE               10
127 #define RSWITCH             9
128 #define RAMPEN              8
129 #define LINEOUTL_SEL        6
130 #define LINEOUTR_SEL        5
131 #define LINEOUT_VOL         0
132 
133 /* AC_MIXER_REG    */
134 #define LMIX_LDAC           21
135 #define LMIX_RDAC           20
136 #define LMIXMUTE            20
137 #define RMIX_RDAC           17
138 #define RMIX_LDAC           16
139 #define RMIXMUTE            16
140 #define LMIXEN              11
141 #define RMIXEN              10
142 #define IOPMIXS             8
143 
144 /* AC_RAMP_REG */
145 #define RAMP_STEP           4
146 #define RMDEN               3
147 #define RMUEN               2
148 #define RMCEN               1
149 #define RDEN                0
150 
151 void T507CodecImplRegmapWrite(uint32_t reg, uint32_t val);
152 void T507CodecImplRegmapRead(uint32_t reg, uint32_t *val);
153 
154 int32_t T507CodecImplGetCtrlOps(const struct AudioKcontrol *kcontrol, struct AudioCtrlElemValue *elemValue);
155 int32_t T507CodecImplSetCtrlOps(const struct AudioKcontrol *kcontrol, const struct AudioCtrlElemValue *elemValue);
156 
157 int32_t T507CodecImplStartup(enum AudioStreamType streamType);
158 int32_t T507CodecImplHwParams(enum AudioStreamType streamType, enum AudioFormat format, uint32_t channels, uint32_t rate);
159 int32_t T507CodecImplTrigger(enum AudioStreamType streamType, bool enable);
160 
161 int32_t T507CodecImplRegDefaultInit(struct AudioRegCfgGroupNode **regCfgGroup);
162 
163 #ifdef __cplusplus
164 #if __cplusplus
165 }
166 #endif
167 #endif /* __cplusplus */
168 
169 #endif /* T507_CODEC_IMPL_LINUX_H */
170