Audio_optek_dapp.c
6.27 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include "c_def.h"
#include "debug.h"
#include "oem.h"
#ifdef AUDIO_OPTEK_DAPP
#include "hw_da_pp.h"
#include "Audio_optek_dapp.h"
#include "Audio_Device.h"
#include "app_main.h"
#include "../dsp/optek_hifi2_dapp.h"
/***************eq layout**********************
total eq: 0~9
eq mode:0~7
bass:8
treble:9
*********************************************/
#define EQ_MODE_INDEX 0
#define BASS_INDEX 8
#define TREBLE_INDEX 9
#define EQ_NUM 8
const int eq_flat_table[EQ_NUM][5] =
{
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
const int eq_classic_table[EQ_NUM][5] =
{
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
const int eq_rock_table[EQ_NUM][5] =
{
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
const int eq_jazz_table[EQ_NUM][5] =
{
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
const int eq_pop_table[EQ_NUM][5] =
{
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
const int bass_table[BASS_MAX+1][5] =
{
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x10000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x30000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x50000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x60000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x70000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x7a000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x7F000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
const int treble_table[TREBLE_MAX+1][5] =
{
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x10000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x30000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x40000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x50000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x60000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x70000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x7a000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x7F000000,0x00000000,0x00000000,0x00000000,0x00000000,
};
void audio_optek_dapp_Init(void)
{
DBG_Printf("%s%\n\r", __func__);
}
void audio_optek_dapp_open(void)
{
DBG_Printf("%s%\n\r", __func__);
audio_optek_dapp_set_volume(app_main_data.volume);
audio_optek_dapp_Set_Bass_Treble(app_main_data.bass,app_main_data.treble);
audio_optek_dapp_set_eq_mode(app_main_data.eq);
}
void audio_optek_dapp_set_channel(U8 channel)
{
DBG_Printf("%s%\n\r", __func__);
}
void audio_optek_dapp_set_volume(U8 volume)
{
int value;
#if (defined RECORD_ENABLE || defined ADC_RECORD)
if (app_main_data.record_status)
{
DBG_Printf("recording now, con not use optek dapp process!\n\r");
return;
}
#endif
DBG_Printf("volume step is:%d\n\r", volume);
if (volume)
{
if (app_main_data.media == MEDIA_AUX)
value = (240+650-60) - volume*650/VOLUME_MAX;
else
value = (240+650) - volume*650/VOLUME_MAX;
}
else
{
value = 240+990;
}
optek_dapp_set_vol(0, value);
optek_dapp_set_vol(1, value);
DBG_Printf("set volume finish:%d db\n\r",24 - value/10);
}
void audio_optek_dapp_Set_Bass_Treble(U8 bass, U8 treble)
{
DBG_Printf("%s\n\r", __func__);
optek_dapp_Appoint_eqData_update(BASS_INDEX,bass_table[bass]);
optek_dapp_Appoint_eqData_update(TREBLE_INDEX,treble_table[treble]);
}
void audio_optek_dapp_set_eq_mode(U8 mode)
{
int i;
int (*table)[5];
int size;
DBG_Printf("%s\n\r", __func__);
switch(mode)
{
case EQ_FLAT:
table = eq_flat_table;
break;
case EQ_CLASSIC:
table = eq_classic_table;
break;
case EQ_ROCK:
table = eq_rock_table;
break;
case EQ_JAZZ:
table = eq_jazz_table;
break;
case EQ_POP:
table = eq_pop_table;
break;
default:
table = eq_flat_table;
DBG_Printf("eq mode set error\n");
break;
}
size = sizeof(eq_flat_table)/sizeof(eq_flat_table[0]) + EQ_MODE_INDEX;
//DBG_Printf("eq_flat_table[%d]\n\r", size);
for (i=EQ_MODE_INDEX; i<size; i++)
{
optek_dapp_Appoint_eqData_update(i, table);
table++;
}
}
void audio_optek_dapp_set_mute(U8 con)
{
//DBG_Printf("%s\n\r", __func__);
}
void audio_optek_dapp_set_AM_mode(U8 con, U32 kFeq)
{
DBG_Printf("%s\n\r", __func__);
}
void audio_optek_dapp_set_speaker(U8 speaker, U8 attenuation)
{
DBG_Printf("%s\n\r", __func__);
}
#endif