blob: 68448ab9a357f5b3f0a0cc4de66c34666edc4e39 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#include <stdio.h>
2#include <unistd.h>
3#include <string.h>
4#include <fcntl.h>
5#include <stdint.h>
6#include <stdbool.h>
7#include <errno.h>
8#include <stdlib.h>
9#include <ctype.h>
10#include <tinyalsa/asoundlib.h>
11#include <sound/asound.h>
12#include <tinyalsa/audio_mixer_ctrl.h>
13
14#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
15
16struct audio_para_conf {
17 const char *control;
18 char *values[2];
19};
20
21
22#if defined _USE_CODEC_TI3100
23
24
25enum t_output_vol {
26 T_OUTPUT_VOL_MINUS_63_5DB = 0,
27 T_OUTPUT_VOL_MINUS_63DB = 1,
28 T_OUTPUT_VOL_MINUS_27DB = 73,
29 T_OUTPUT_VOL_MINUS_24DB = 79,
30 T_OUTPUT_VOL_MINUS_21DB = 85,
31 T_OUTPUT_VOL_MINUS_18DB = 91,
32 T_OUTPUT_VOL_MINUS_15DB = 97,
33 T_OUTPUT_VOL_MINUS_12DB = 103,
34 T_OUTPUT_VOL_MINUS_9DB = 109,
35 T_OUTPUT_VOL_MINUS_6DB = 115,
36 T_OUTPUT_VOL_MINUS_3DB = 121,
37 T_OUTPUT_VOL_MINUS_2DB = 123,
38 T_OUTPUT_VOL_MINUS_1DB = 125,
39 T_OUTPUT_VOL_0DB = 127,
40 T_OUTPUT_VOL_1DB = 129,
41 T_OUTPUT_VOL_2DB = 131,
42 T_OUTPUT_VOL_3DB = 133,
43 T_OUTPUT_VOL_6DB = 139,
44 T_OUTPUT_VOL_9DB = 145,
45 T_OUTPUT_VOL_12DB = 151,
46 T_OUTPUT_VOL_24DB = 175,
47};
48
49enum t_input_vol {
50 T_INPUT_VOL_MINUS_12DB = 0,
51 T_INPUT_VOL_MINUS_7DB = 10,
52 T_INPUT_VOL_MINUS_6DB = 12,
53 T_INPUT_VOL_MINUS_5DB = 14,
54 T_INPUT_VOL_MINUS_4DB = 16,
55 T_INPUT_VOL_MINUS_3DB = 18,
56 T_INPUT_VOL_MINUS_2DB = 20,
57 T_INPUT_VOL_MINUS_1DB = 22,
58 T_INPUT_VOL_0DB = 24,
59 T_INPUT_VOL_1DB = 26,
60 T_INPUT_VOL_2DB = 28,
61 T_INPUT_VOL_3DB = 30,
62 T_INPUT_VOL_20DB = 64,
63};
64
65static struct audio_para_conf init_default_para[] = { //¿ª»ú³õʼ»¯µ÷ÓÃ
66 {"Mic PGA Capture Volume", {"40"}},
67 {"ADC Mute", {"0"}},
68 {"ADC Fine Capture Volume", {"0"}},
69 {"Speaker Analog Playback Volume", {"127"}},
70 {"Speaker Driver Playback Switch", {"1"}},
71 {"DAC Left Input", {"Mono"}},
72 {"DAC Right Input", {"Mono"}},
73 {"Output Right From Right DAC", {"1"}},
74 {"Output Left From Left DAC", {"1"}},
75 {"HP Analog Playback Volume", {"127", "127"}},
76 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
77};
78
79#ifdef _USE_7520V3_PHONE_TYPE_FWP
80static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
81 {"Speaker Analog Playback Volume", {"127"}},
82 {"Speaker Driver Playback Switch", {"1"}},
83 {"DAC Left Input", {"Mono"}},
84 {"DAC Right Input", {"Mono"}},
85 {"Output Right From Right DAC", {"1"}},
86 {"Output Left From Left DAC", {"1"}},
87 {"HP Analog Playback Volume", {"127", "127"}},
88 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
89};
90
91static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
92 {"Mic PGA Capture Volume", {"12"}},
93 {"ADC Mute", {"0"}},
94 {"ADC Fine Capture Volume", {"0"}},
95
96};
97
98static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ
99 {"Speaker Switch", {"0"}},
100 {"HP Left Switch", {"1"}},
101 {"HP Right Switch", {"1"}},
102 {"HP Driver Playback Volume", {"0", "0"}},
103};
104
105static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ
106 {"Speaker Switch", {"1"}},
107 {"Speaker Driver Playback Volume", {"2"}}, //18dB
108 {"HP Left Switch", {"0"}},
109 {"HP Right Switch", {"0"}},
110};
111
112static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ
113 {"MIC1LM P-Terminal", {"Off"}},
114 {"MIC1RP P-Terminal", {"Off"}},
115 {"MIC1LP P-Terminal", {"FFR 10 Ohm"}},
116 {"MIC1LM M-Terminal", {"FFR 10 Ohm"}},
117
118};
119
120static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ
121 {"MIC1LM P-Terminal", {"Off"}},
122 {"MIC1RP P-Terminal", {"FFR 10 Ohm"}},
123 {"MIC1LP P-Terminal", {"Off"}},
124 {"MIC1LM M-Terminal", {"Off"}},
125};
126
127static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
128 {"Mic PGA Capture Volume", {"12"}},
129 //{"ADC Mute", {"0"}},
130 //{"ADC Fine Capture Volume", {"0"}},
131 {"DAC Left Input", {"Mono"}},
132 {"DAC Right Input", {"Mono"}},
133 {"Output Right From Right DAC", {"1"}},
134 {"Output Left From Left DAC", {"1"}},
135 {"HP Analog Playback Volume", {"127", "127"}},
136 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
137 {"Speaker Switch", {"0"}},
138 {"DAC Playback Volume", {"129", "129"}},
139 {"HP Left Switch", {"1"}},
140 {"HP Right Switch", {"1"}},
141 {"HP Driver Playback Volume", {"5", "5"}},
142 {"MIC1LM P-Terminal", {"Off"}},
143 {"MIC1RP P-Terminal", {"Off"}},
144 {"MIC1LP P-Terminal", {"FFR 10 Ohm"}},
145 {"MIC1LM M-Terminal", {"FFR 10 Ohm"}},
146 {"ADC Capture Volume", {"24"}},
147 {"voice processing path select", {"handset"}}, // handset speak headset bluetooth
148};
149
150static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ
151 {"Mic PGA Capture Volume", {"40"}},
152 //{"ADC Mute", {"0"}},
153 //{"ADC Fine Capture Volume", {"0"}},
154 {"DAC Left Input", {"Mono"}},
155 {"DAC Right Input", {"Mono"}},
156 {"Output Right From Right DAC", {"1"}},
157 {"Output Left From Left DAC", {"1"}},
158 {"HP Analog Playback Volume", {"127", "127"}},
159 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
160 {"Speaker Switch", {"0"}},
161 {"DAC Playback Volume ", {"129", "129"}},
162 {"HP Left Switch", {"1"}},
163 {"HP Right Switch", {"1"}},
164 {"HP Driver Playback Switch", {"7", "7"}}, //7dB
165 {"MIC1LM P-Terminal", {"Off"}},
166 {"MIC1RP P-Terminal", {"FFR 10 Ohm"}},
167 {"MIC1LP P-Terminal", {"Off"}},
168 {"MIC1LM M-Terminal", {"Off"}},
169 {"ADC Capture Volume", {"24"}},
170 {"voice processing select", {"headset"}}, // handset speak headset bluetooth
171};
172
173static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
174 {"Mic PGA Capture Volume", {"12"}},
175 //{"ADC Mute", {"0"}},
176 //{"ADC Fine Capture Volume", {"0"}},
177 {"Speaker Analog Playback Volume", {"127"}},
178 {"Speaker Driver Playback Switch", {"1"}},
179 {"DAC Left Input", {"Mono"}},
180 {"DAC Right Input", {"Mono"}},
181 {"Output Right From Right DAC", {"1"}},
182 {"Output Left From Left DAC", {"1"}},
183 {"DAC Playback Volume", {"124", "124"}}, //-1.5dB
184 {"Speaker Switch", {"1"}},
185 {"Speaker Driver Playback Volume", {"0"}}, //18dB
186 {"HP Left Switch", {"0"}},
187 {"HP Right Switch", {"0"}},
188 {"MIC1LM P-Terminal", {"Off"}},
189 {"MIC1RP P-Terminal", {"Off"}},
190 {"MIC1LP P-Terminal", {"FFR 10 Ohm"}},
191 {"MIC1LM M-Terminal", {"FFR 10 Ohm"}},
192 {"ADC Capture Volume", {"24"}},
193 {"voice processing path select", {"speak"}}, // handset speak headset bluetooth
194};
195
196#else
197static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
198 {"Speaker Analog Playback Volume", {"127"}},
199 {"Speaker Driver Playback Switch", {"1"}},
200 {"DAC Left Input", {"Mono"}},
201 {"DAC Right Input", {"Mono"}},
202 {"Output Right From Right DAC", {"1"}},
203 {"Output Left From Left DAC", {"1"}},
204 {"HP Analog Playback Volume", {"127", "127"}},
205 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
206};
207
208static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
209 {"Mic PGA Capture Volume", {"40"}},
210 {"ADC Mute", {"0"}},
211 {"ADC Fine Capture Volume", {"0"}},
212
213};
214
215static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ
216 {"Speaker Switch", {"0"}},
217 {"HP Left Switch", {"1"}},
218 {"HP Right Switch", {"1"}},
219 {"HP Driver Playback Volume", {"0", "0"}},
220};
221
222static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ
223 {"Speaker Switch", {"1"}},
224 {"Speaker Driver Playback Volume", {"2"}}, //18dB
225 {"HP Left Switch", {"0"}},
226 {"HP Right Switch", {"0"}},
227};
228
229static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ
230 {"MIC1LM P-Terminal", {"Off"}},
231 {"MIC1RP P-Terminal", {"Off"}},
232 {"MIC1LP P-Terminal", {"FFR 10 Ohm"}},
233 {"MIC1LM M-Terminal", {"FFR 10 Ohm"}},
234
235};
236
237static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ
238 {"MIC1LM P-Terminal", {"Off"}},
239 {"MIC1RP P-Terminal", {"FFR 10 Ohm"}},
240 {"MIC1LP P-Terminal", {"Off"}},
241 {"MIC1LM M-Terminal", {"Off"}},
242};
243
244static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
245 {"Mic PGA Capture Volume", {"40"}},
246 //{"ADC Mute", {"0"}},
247 //{"ADC Fine Capture Volume", {"0"}},
248 {"DAC Left Input", {"Mono"}},
249 {"DAC Right Input", {"Mono"}},
250 {"Output Right From Right DAC", {"1"}},
251 {"Output Left From Left DAC", {"1"}},
252 {"HP Analog Playback Volume", {"127", "127"}},
253 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
254 {"Speaker Switch", {"0"}},
255 {"DAC Playback Volume", {"129", "129"}},
256 {"HP Left Switch", {"1"}},
257 {"HP Right Switch", {"1"}},
258 {"HP Driver Playback Volume", {"7", "7"}},
259 {"MIC1LM P-Terminal", {"Off"}},
260 {"MIC1RP P-Terminal", {"Off"}},
261 {"MIC1LP P-Terminal", {"FFR 10 Ohm"}},
262 {"MIC1LM M-Terminal", {"FFR 10 Ohm"}},
263 {"ADC Capture Volume", {"24"}},
264 {"voice processing path select", {"handset"}}, // handset speak headset bluetooth
265};
266
267static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ
268 {"Mic PGA Capture Volume", {"40"}},
269 //{"ADC Mute", {"0"}},
270 //{"ADC Fine Capture Volume", {"0"}},
271 {"DAC Left Input", {"Mono"}},
272 {"DAC Right Input", {"Mono"}},
273 {"Output Right From Right DAC", {"1"}},
274 {"Output Left From Left DAC", {"1"}},
275 {"HP Analog Playback Volume", {"127", "127"}},
276 {"HP Driver Playback Switch", {"1", "1"}}, //7dB
277 {"Speaker Switch", {"0"}},
278 {"DAC Playback Volume ", {"129", "129"}},
279 {"HP Left Switch", {"1"}},
280 {"HP Right Switch", {"1"}},
281 {"HP Driver Playback Switch", {"7", "7"}}, //7dB
282 {"MIC1LM P-Terminal", {"Off"}},
283 {"MIC1RP P-Terminal", {"FFR 10 Ohm"}},
284 {"MIC1LP P-Terminal", {"Off"}},
285 {"MIC1LM M-Terminal", {"Off"}},
286 {"ADC Capture Volume", {"24"}},
287 {"voice processing select", {"headset"}}, // handset speak headset bluetooth
288};
289
290static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
291 {"Mic PGA Capture Volume", {"20"}},
292 //{"ADC Mute", {"0"}},
293 //{"ADC Fine Capture Volume", {"0"}},
294 {"Speaker Analog Playback Volume", {"127"}},
295 {"Speaker Driver Playback Switch", {"1"}},
296 {"DAC Left Input", {"Mono"}},
297 {"DAC Right Input", {"Mono"}},
298 {"Output Right From Right DAC", {"1"}},
299 {"Output Left From Left DAC", {"1"}},
300 {"DAC Playback Volume", {"124", "124"}}, //-1.5dB
301 {"Speaker Switch", {"1"}},
302 {"Speaker Driver Playback Volume", {"2"}}, //18dB
303 {"HP Left Switch", {"0"}},
304 {"HP Right Switch", {"0"}},
305 {"MIC1LM P-Terminal", {"Off"}},
306 {"MIC1RP P-Terminal", {"Off"}},
307 {"MIC1LP P-Terminal", {"FFR 10 Ohm"}},
308 {"MIC1LM M-Terminal", {"FFR 10 Ohm"}},
309 {"ADC Capture Volume", {"24"}},
310 {"voice processing path select", {"speak"}}, // handset speak headset bluetooth
311};
312
313#endif
314static struct audio_para_conf output_dac_vol = {"DAC Playback Volume", {"129","129"}};
315
316static struct audio_para_conf input_adc_vol = {"ADC Capture Volume", {"24"}};
317
318static struct audio_para_conf dac_mute = {"DAC Mute", {"1", "1"}};
319static struct audio_para_conf adc_mute = {"ADC Mute", {"1"}};
320
321static struct audio_para_conf spk_path_onoff[] = {
322 {"Speaker Switch", {"0"}},
323};
324static struct audio_para_conf rcv_path_onoff[] = {
325 {"HP Left Switch", {"0"}},
326 {"HP Right Switch", {"0"}},
327};
328static struct audio_para_conf earp_path_onoff[] = {
329 {"HP Left Switch", {"0"}},
330 {"HP Right Switch", {"0"}},
331};
332static int output_vol_conversion(int vol)
333{
334 switch(vol){
335 case T_AUDIO_OUTPUT_VOL_LEVEL_0:
336 return T_OUTPUT_VOL_MINUS_63_5DB;
337 case T_AUDIO_OUTPUT_VOL_LEVEL_1:
338 return T_OUTPUT_VOL_MINUS_27DB;
339 case T_AUDIO_OUTPUT_VOL_LEVEL_2:
340 return T_OUTPUT_VOL_MINUS_24DB;
341 case T_AUDIO_OUTPUT_VOL_LEVEL_3:
342 return T_OUTPUT_VOL_MINUS_21DB;
343 case T_AUDIO_OUTPUT_VOL_LEVEL_4:
344 return T_OUTPUT_VOL_MINUS_18DB;
345 case T_AUDIO_OUTPUT_VOL_LEVEL_5:
346 return T_OUTPUT_VOL_MINUS_15DB;
347 case T_AUDIO_OUTPUT_VOL_LEVEL_6:
348 return T_OUTPUT_VOL_MINUS_12DB;
349 case T_AUDIO_OUTPUT_VOL_LEVEL_7:
350 return T_OUTPUT_VOL_MINUS_9DB;
351 case T_AUDIO_OUTPUT_VOL_LEVEL_8:
352 return T_OUTPUT_VOL_MINUS_6DB;
353 case T_AUDIO_OUTPUT_VOL_LEVEL_9:
354 return T_OUTPUT_VOL_MINUS_3DB;
355 case T_AUDIO_OUTPUT_VOL_LEVEL_10:
356 return T_OUTPUT_VOL_0DB;
357 case T_AUDIO_OUTPUT_VOL_LEVEL_11:
358 return T_OUTPUT_VOL_3DB;
359 default:
360 return T_OUTPUT_VOL_0DB;
361 }
362}
363
364static int input_vol_conversion(int vol)
365{
366 switch(vol) {
367 case T_AUDIO_INPUT_VOL_LEVEL_0:
368 return T_INPUT_VOL_MINUS_12DB;
369 case T_AUDIO_INPUT_VOL_LEVEL_1:
370 return T_INPUT_VOL_MINUS_7DB;
371 case T_AUDIO_INPUT_VOL_LEVEL_2:
372 return T_INPUT_VOL_MINUS_6DB;
373 case T_AUDIO_INPUT_VOL_LEVEL_3:
374 return T_INPUT_VOL_MINUS_5DB;
375 case T_AUDIO_INPUT_VOL_LEVEL_4:
376 return T_INPUT_VOL_MINUS_4DB;
377 case T_AUDIO_INPUT_VOL_LEVEL_5:
378 return T_INPUT_VOL_MINUS_3DB;
379 case T_AUDIO_INPUT_VOL_LEVEL_6:
380 return T_INPUT_VOL_MINUS_2DB;
381 case T_AUDIO_INPUT_VOL_LEVEL_7:
382 return T_INPUT_VOL_MINUS_1DB;
383 case T_AUDIO_INPUT_VOL_LEVEL_8:
384 return T_INPUT_VOL_0DB;
385 case T_AUDIO_INPUT_VOL_LEVEL_9:
386 return T_INPUT_VOL_1DB;
387 case T_AUDIO_INPUT_VOL_LEVEL_10:
388 return T_INPUT_VOL_2DB;
389 case T_AUDIO_INPUT_VOL_LEVEL_11:
390 return T_INPUT_VOL_3DB;
391 default:
392 return T_INPUT_VOL_0DB;
393 }
394}
395
396
397#elif defined _USE_CODEC_ES8374
398
399
400enum t_output_vol {
401 T_OUTPUT_VOL_MINUS_96DB = 0,
402 T_OUTPUT_VOL_MINUS_95DB = 2,
403 T_OUTPUT_VOL_MINUS_90DB = 12,
404 T_OUTPUT_VOL_MINUS_85DB = 22,
405 T_OUTPUT_VOL_MINUS_80DB = 32,
406 T_OUTPUT_VOL_MINUS_75DB = 42,
407 T_OUTPUT_VOL_MINUS_70DB = 52,
408 T_OUTPUT_VOL_MINUS_65DB = 62,
409 T_OUTPUT_VOL_MINUS_60DB = 72,
410 T_OUTPUT_VOL_MINUS_55DB = 82,
411 T_OUTPUT_VOL_MINUS_50DB = 92,
412 T_OUTPUT_VOL_MINUS_45DB = 102,
413 T_OUTPUT_VOL_MINUS_40DB = 112,
414 T_OUTPUT_VOL_MINUS_35DB = 122,
415 T_OUTPUT_VOL_MINUS_30DB = 132,
416 T_OUTPUT_VOL_MINUS_25DB = 142,
417 T_OUTPUT_VOL_MINUS_20DB = 152,
418 T_OUTPUT_VOL_MINUS_15DB = 162,
419 T_OUTPUT_VOL_MINUS_10DB = 172,
420 T_OUTPUT_VOL_MINUS_7DB = 178,
421 T_OUTPUT_VOL_MINUS_6DB = 180,
422 T_OUTPUT_VOL_MINUS_5DB = 182,
423 T_OUTPUT_VOL_MINUS_4DB = 184,
424 T_OUTPUT_VOL_MINUS_3DB = 186,
425 T_OUTPUT_VOL_MINUS_2DB = 188,
426 T_OUTPUT_VOL_MINUS_1DB = 190,
427 T_OUTPUT_VOL_0DB = 192
428};
429
430enum t_input_vol {
431 T_INPUT_VOL_MINUS_96DB = 0,
432 T_INPUT_VOL_MINUS_95DB = 2,
433 T_INPUT_VOL_MINUS_90DB = 12,
434 T_INPUT_VOL_MINUS_85DB = 22,
435 T_INPUT_VOL_MINUS_80DB = 32,
436 T_INPUT_VOL_MINUS_75DB = 42,
437 T_INPUT_VOL_MINUS_70DB = 52,
438 T_INPUT_VOL_MINUS_65DB = 62,
439 T_INPUT_VOL_MINUS_60DB = 72,
440 T_INPUT_VOL_MINUS_55DB = 82,
441 T_INPUT_VOL_MINUS_50DB = 92,
442 T_INPUT_VOL_MINUS_45DB = 102,
443 T_INPUT_VOL_MINUS_40DB = 112,
444 T_INPUT_VOL_MINUS_35DB = 122,
445 T_INPUT_VOL_MINUS_30DB = 132,
446 T_INPUT_VOL_MINUS_25DB = 142,
447 T_INPUT_VOL_MINUS_20DB = 152,
448 T_INPUT_VOL_MINUS_15DB = 162,
449 T_INPUT_VOL_MINUS_10DB = 172,
450 T_INPUT_VOL_MINUS_7DB = 178,
451 T_INPUT_VOL_MINUS_6DB = 180,
452 T_INPUT_VOL_MINUS_5DB = 182,
453 T_INPUT_VOL_MINUS_4DB = 184,
454 T_INPUT_VOL_MINUS_3DB = 186,
455 T_INPUT_VOL_MINUS_2DB = 188,
456 T_INPUT_VOL_MINUS_1DB = 190,
457 T_INPUT_VOL_0DB = 192
458};
459
460
461static struct audio_para_conf init_default_para[] = { //¿ª»ú³õʼ»¯µ÷ÓÃ
462 {"DMIC MUX", {"0"}},
463 {"SDP OUT MUX", {"0"}},
464 {"ALC MUX", {"0"}},
465 {"D2SE MIC BOOST GAIN", {"1"}},
466 {"LIN PGA GAIN", {"6"}},
467 {"ADC Capture Volume", {"192"}},
468 {"ALC Capture Max PGA", {"15"}},
469 {"DAC MUTE", {"0"}},
470 {"DAC Playback Volume", {"120"}},
471 {"DAC SDP SRC MUX", {"0"}},
472 {"DAC SRC MUX", {"0"}}
473};
474
475//#ifdef _USE_7520V3_PHONE_TYPE_C31F
476#if ( defined _USE_7520V3_PHONE_TYPE_C31F || defined _USE_7520V3_PHONE_TYPE_WTWD )
477
478static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
479 {"DAC MUTE", {"0"}},
480 //{"DAC Playback Volume", {"120"}},
481 {"DAC SDP SRC MUX", {"0"}},
482 {"DAC SRC MUX", {"0"}}
483};
484
485static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
486 {"DMIC MUX", {"0"}},
487 {"SDP OUT MUX", {"0"}},
488 {"ADC Soft Ramp", {"0"}},
489 {"ADC HPF COEFFICIENT", {"5"}},
490#if 0
491 {"ALC MUX", {"1"}},
492 {"ALC Capture Target Volume", {"5"}},
493 {"ALC Capture Max PGA", {"11"}},
494 {"ALC Capture Min PGA", {"2"}},
495 {"ALC Capture Hold Time", {"0"}},
496 {"ALC Capture Decay Time", {"0"}},
497 {"ALC Capture Attack Time", {"0"}},
498 {"ALC WIN SIZE", {"6"}},
499 {"ALC Capture NG Threshold", {"14"}},
500 {"ALC Capture NG Type", {"0"}},
501 {"ALC Capture NG Switch", {"0"}},
502#endif
503 {"D2SE MIC BOOST GAIN", {"1"}},
504 {"LIN PGA GAIN", {"6"}},
505 {"ADC Capture Volume", {"192"}},
506};
507
508#ifdef _USE_7520V3_PHONE_TYPE_WTWD
509static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ
510 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
511 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}},
512 {"SPEAKER MIXER GAIN", {"41"}}, //1d
513 {"SPEAKER OUTPUT Volume", {"0"}}, //1e
514 {"DAC Playback Volume", {"192"}}, //38
515};
516#else
517static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ
518 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
519 {"MONO OUT GAIN", {"4"}},
520 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
521 {"audio path select",{"handset"}},
522};
523
524#endif
525/*
526static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ
527 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
528 {"SPEAKER MIXER GAIN", {"4"}},
529 {"SPEAKER OUTPUT Volume", {"4"}},
530 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}}
531};
532*/
533
534static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ
535 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
536 {"MONO OUT GAIN", {"11"}},
537 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
538 {"audio path select",{"speak"}},
539};
540
541static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚLin1-Rin1ÊäÈëͨµÀ
542 {"DIFFERENTIAL MUX", {"1"}},
543};
544
545static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚLin2-Rin2ÊäÈëͨµÀ
546 {"DIFFERENTIAL MUX", {"2"}},
547};
548
549#ifdef _USE_7520V3_PHONE_TYPE_WTWD
550
551static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
552 //{"voice processing path select", {"headset"}}, // handset speak headset bluetooth
553 {"voice processing path select", {"handset"}}, // handset speak headset bluetooth
554 {"DIFFERENTIAL MUX", {"1"}},
555 {"DMIC MUX", {"0"}},
556 {"SDP OUT MUX", {"0"}},
557 {"ADC Soft Ramp", {"0"}},
558 {"ADC HPF COEFFICIENT", {"5"}},
559
560 {"ALC MUX", {"0"}},
561 {"D2SE MIC BOOST GAIN", {"1"}},
562 {"LIN PGA GAIN", {"6"}},
563 {"ADC Capture Volume", {"192"}},
564
565 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
566 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}},
567 {"SPEAKER MIXER GAIN", {"32"}}, //old 41
568 {"SPEAKER OUTPUT Volume", {"0"}}, //1
569 {"DAC Playback Volume", {"192"}}, //38
570};
571
572#else
573static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
574 {"voice processing path select", {"handset"}}, // handset speak headset bluetooth
575 {"DIFFERENTIAL MUX", {"1"}},
576 {"DMIC MUX", {"0"}},
577 {"SDP OUT MUX", {"0"}},
578 {"ADC Soft Ramp", {"0"}},
579 {"ADC HPF COEFFICIENT", {"5"}},
580
581 {"ALC MUX", {"0"}},
582#if 0
583 {"ALC Capture Target Volume", {"7"}},
584 {"ALC Capture Max PGA", {"13"}},
585 {"ALC Capture Min PGA", {"8"}},
586 {"ALC Capture Hold Time", {"0"}},
587 {"ALC Capture Decay Time", {"1"}},
588 {"ALC Capture Attack Time", {"2"}},
589 {"ALC WIN SIZE", {"6"}},
590 {"ALC Capture NG Threshold", {"14"}},
591 {"ALC Capture NG Type", {"0"}},
592 {"ALC Capture NG Switch", {"0"}},
593#endif
594 {"D2SE MIC BOOST GAIN", {"1"}},
595 {"LIN PGA GAIN", {"6"}},
596 {"ADC Capture Volume", {"192"}},
597 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
598 {"MONO OUT GAIN", {"11"}},
599 {"DAC Playback Volume", {"192"}},
600 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
601};
602#endif
603static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ
604 {"DIFFERENTIAL MUX", {"1"}},
605 {"DMIC MUX", {"0"}},
606 {"SDP OUT MUX", {"0"}},
607 {"ADC Soft Ramp", {"0"}},
608 {"ADC HPF COEFFICIENT", {"5"}},
609
610 {"ALC MUX", {"0"}},
611#if 0
612 {"ALC Capture Target Volume", {"7"}},
613 {"ALC Capture Max PGA", {"13"}},
614 {"ALC Capture Min PGA", {"8"}},
615 {"ALC Capture Hold Time", {"0"}},
616 {"ALC Capture Decay Time", {"1"}},
617 {"ALC Capture Attack Time", {"2"}},
618 {"ALC WIN SIZE", {"6"}},
619 {"ALC Capture NG Threshold", {"14"}},
620 {"ALC Capture NG Type", {"0"}},
621 {"ALC Capture NG Switch", {"0"}},
622#endif
623 {"D2SE MIC BOOST GAIN", {"1"}},
624 {"LIN PGA GAIN", {"7"}},
625 {"ADC Capture Volume", {"192"}},
626 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
627 {"MONO OUT GAIN", {"4"}},
628 {"DAC Playback Volume", {"190"}},
629 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
630 {"voice processing select", {"headset"}}, // handset speak headset bluetooth
631};
632#ifdef _USE_7520V3_PHONE_TYPE_WTWD //class-d -->receiver
633static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
634 {"DIFFERENTIAL MUX", {"1"}},
635 {"DMIC MUX", {"0"}},
636 {"SDP OUT MUX", {"0"}},
637 {"ADC Soft Ramp", {"0"}},
638 {"ADC HPF COEFFICIENT", {"5"}},
639
640 {"ALC MUX", {"0"}},
641#if 0
642 {"ALC Capture Target Volume", {"7"}},
643 {"ALC Capture Max PGA", {"13"}},
644 {"ALC Capture Min PGA", {"8"}},
645 {"ALC Capture Hold Time", {"0"}},
646 {"ALC Capture Decay Time", {"1"}},
647 {"ALC Capture Attack Time", {"2"}},
648 {"ALC WIN SIZE", {"6"}},
649 {"ALC Capture NG Threshold", {"14"}},
650 {"ALC Capture NG Type", {"0"}},
651 {"ALC Capture NG Switch", {"0"}},
652#endif
653 {"D2SE MIC BOOST GAIN", {"1"}},
654 {"LIN PGA GAIN", {"6"}},
655 {"ADC Capture Volume", {"192"}},
656 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
657 {"MONO OUT GAIN", {"4"}},
658 {"DAC Playback Volume", {"186"}},
659 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
660 {"voice processing path select", {"speak"}}, // handset speak headset bluetooth
661};
662#else//momo out -> speaker
663static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
664 {"DIFFERENTIAL MUX", {"1"}},
665 {"DMIC MUX", {"0"}},
666 {"SDP OUT MUX", {"0"}},
667 {"ADC Soft Ramp", {"0"}},
668 {"ADC HPF COEFFICIENT", {"5"}},
669
670 {"ALC MUX", {"0"}},
671#if 0
672 {"ALC Capture Target Volume", {"7"}},
673 {"ALC Capture Max PGA", {"13"}},
674 {"ALC Capture Min PGA", {"8"}},
675 {"ALC Capture Hold Time", {"0"}},
676 {"ALC Capture Decay Time", {"1"}},
677 {"ALC Capture Attack Time", {"2"}},
678 {"ALC WIN SIZE", {"6"}},
679 {"ALC Capture NG Threshold", {"14"}},
680 {"ALC Capture NG Type", {"0"}},
681 {"ALC Capture NG Switch", {"0"}},
682#endif
683 {"D2SE MIC BOOST GAIN", {"1"}},
684 {"LIN PGA GAIN", {"6"}},
685 {"ADC Capture Volume", {"192"}},
686 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
687 {"MONO OUT GAIN", {"0"}},
688 {"DAC Playback Volume", {"186"}},
689 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
690 {"voice processing path select", {"speak"}}, // handset speak headset bluetooth
691};
692
693#endif
694
695
696
697#else
698static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
699 {"DAC MUTE", {"0"}},
700 //{"DAC Playback Volume", {"120"}},
701 {"DAC SDP SRC MUX", {"0"}},
702 {"DAC SRC MUX", {"0"}}
703};
704
705static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö
706 {"DMIC MUX", {"0"}},
707 {"SDP OUT MUX", {"0"}},
708 {"ADC Soft Ramp", {"0"}},
709 {"ADC HPF COEFFICIENT", {"5"}},
710#if 1
711 {"ALC MUX", {"1"}},
712 {"ALC Capture Target Volume", {"5"}},
713 {"ALC Capture Max PGA", {"11"}},
714 {"ALC Capture Min PGA", {"2"}},
715 {"ALC Capture Hold Time", {"0"}},
716 {"ALC Capture Decay Time", {"0"}},
717 {"ALC Capture Attack Time", {"0"}},
718 {"ALC WIN SIZE", {"6"}},
719 {"ALC Capture NG Threshold", {"14"}},
720 {"ALC Capture NG Type", {"0"}},
721 {"ALC Capture NG Switch", {"0"}},
722#endif
723 {"D2SE MIC BOOST GAIN", {"1"}},
724 {"LIN PGA GAIN", {"3"}},
725 {"ADC Capture Volume", {"180"}},
726};
727
728static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ
729 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
730 {"MONO OUT GAIN", {"4"}},
731 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}
732};
733
734/*
735static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ
736 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
737 {"SPEAKER MIXER GAIN", {"4"}},
738 {"SPEAKER OUTPUT Volume", {"4"}},
739 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}}
740};
741*/
742
743static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ
744 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
745 {"MONO OUT GAIN", {"3"}},
746 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}
747};
748
749static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚLin1-Rin1ÊäÈëͨµÀ
750 {"DIFFERENTIAL MUX", {"1"}},
751};
752
753static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚLin2-Rin2ÊäÈëͨµÀ
754 {"DIFFERENTIAL MUX", {"2"}},
755};
756
757static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
758 {"DIFFERENTIAL MUX", {"1"}},
759 {"DMIC MUX", {"0"}},
760 {"SDP OUT MUX", {"0"}},
761 {"ADC Soft Ramp", {"0"}},
762 {"ADC HPF COEFFICIENT", {"5"}},
763
764 {"ALC MUX", {"0"}},
765#if 0
766 {"ALC Capture Target Volume", {"7"}},
767 {"ALC Capture Max PGA", {"13"}},
768 {"ALC Capture Min PGA", {"8"}},
769 {"ALC Capture Hold Time", {"0"}},
770 {"ALC Capture Decay Time", {"1"}},
771 {"ALC Capture Attack Time", {"2"}},
772 {"ALC WIN SIZE", {"6"}},
773 {"ALC Capture NG Threshold", {"14"}},
774 {"ALC Capture NG Type", {"0"}},
775 {"ALC Capture NG Switch", {"0"}},
776#endif
777 {"D2SE MIC BOOST GAIN", {"1"}},
778 {"LIN PGA GAIN", {"7"}},
779 {"ADC Capture Volume", {"192"}},
780 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
781 {"MONO OUT GAIN", {"4"}},
782 {"DAC Playback Volume", {"190"}},
783 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
784 {"voice processing path select", {"handset"}}, // handset speak headset bluetooth
785};
786
787static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ
788 {"DIFFERENTIAL MUX", {"1"}},
789 {"DMIC MUX", {"0"}},
790 {"SDP OUT MUX", {"0"}},
791 {"ADC Soft Ramp", {"0"}},
792 {"ADC HPF COEFFICIENT", {"5"}},
793
794 {"ALC MUX", {"0"}},
795#if 0
796 {"ALC Capture Target Volume", {"7"}},
797 {"ALC Capture Max PGA", {"13"}},
798 {"ALC Capture Min PGA", {"8"}},
799 {"ALC Capture Hold Time", {"0"}},
800 {"ALC Capture Decay Time", {"1"}},
801 {"ALC Capture Attack Time", {"2"}},
802 {"ALC WIN SIZE", {"6"}},
803 {"ALC Capture NG Threshold", {"14"}},
804 {"ALC Capture NG Type", {"0"}},
805 {"ALC Capture NG Switch", {"0"}},
806#endif
807 {"D2SE MIC BOOST GAIN", {"1"}},
808 {"LIN PGA GAIN", {"7"}},
809 {"ADC Capture Volume", {"192"}},
810 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
811 {"MONO OUT GAIN", {"4"}},
812 {"DAC Playback Volume", {"190"}},
813 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
814 {"voice processing select", {"headset"}}, // handset speak headset bluetooth
815};
816
817static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ
818 {"DIFFERENTIAL MUX", {"1"}},
819 {"DMIC MUX", {"0"}},
820 {"SDP OUT MUX", {"0"}},
821 {"ADC Soft Ramp", {"0"}},
822 {"ADC HPF COEFFICIENT", {"5"}},
823
824 {"ALC MUX", {"0"}},
825#if 0
826 {"ALC Capture Target Volume", {"7"}},
827 {"ALC Capture Max PGA", {"13"}},
828 {"ALC Capture Min PGA", {"8"}},
829 {"ALC Capture Hold Time", {"0"}},
830 {"ALC Capture Decay Time", {"1"}},
831 {"ALC Capture Attack Time", {"2"}},
832 {"ALC WIN SIZE", {"6"}},
833 {"ALC Capture NG Threshold", {"14"}},
834 {"ALC Capture NG Type", {"0"}},
835 {"ALC Capture NG Switch", {"0"}},
836#endif
837 {"D2SE MIC BOOST GAIN", {"1"}},
838 {"LIN PGA GAIN", {"7"}},
839 {"ADC Capture Volume", {"192"}},
840 {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}},
841 {"MONO OUT GAIN", {"4"}},
842 {"DAC Playback Volume", {"190"}},
843 {"MONO MIXER DAC TO MONO OUT Switch", {"1"}},
844 {"voice processing path select", {"speak"}}, // handset speak headset bluetooth
845};
846
847#endif
848
849static struct audio_para_conf output_dac_vol = {"DAC Playback Volume", {"120"}};
850
851static struct audio_para_conf input_adc_vol = {"ADC Capture Volume", {"192"}};
852
853static struct audio_para_conf dac_mute = {"DAC MUTE", {"1"}};
854static struct audio_para_conf adc_mute = {"ADC MUTE", {"1"}};
855
856static struct audio_para_conf spk_path_onoff[] = {
857 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
858};
859
860static struct audio_para_conf rcv_path_onoff[] = {
861 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
862};
863
864static struct audio_para_conf earp_path_onoff[] = {
865 {"MONO MIXER DAC TO MONO OUT Switch", {"0"}},
866};
867
868
869static int output_vol_conversion(int vol)
870{
871 switch(vol){
872 case T_AUDIO_OUTPUT_VOL_LEVEL_0:
873 return T_OUTPUT_VOL_MINUS_96DB;
874 case T_AUDIO_OUTPUT_VOL_LEVEL_1:
875 return T_OUTPUT_VOL_MINUS_45DB;
876 case T_AUDIO_OUTPUT_VOL_LEVEL_2:
877 return T_OUTPUT_VOL_MINUS_40DB;
878 case T_AUDIO_OUTPUT_VOL_LEVEL_3:
879 return T_OUTPUT_VOL_MINUS_35DB;
880 case T_AUDIO_OUTPUT_VOL_LEVEL_4:
881 return T_OUTPUT_VOL_MINUS_30DB;
882 case T_AUDIO_OUTPUT_VOL_LEVEL_5:
883 return T_OUTPUT_VOL_MINUS_25DB;
884 case T_AUDIO_OUTPUT_VOL_LEVEL_6:
885 return T_OUTPUT_VOL_MINUS_20DB;
886 case T_AUDIO_OUTPUT_VOL_LEVEL_7:
887 return T_OUTPUT_VOL_MINUS_15DB;
888 case T_AUDIO_OUTPUT_VOL_LEVEL_8:
889 return T_OUTPUT_VOL_MINUS_10DB;
890 case T_AUDIO_OUTPUT_VOL_LEVEL_9:
891 return T_OUTPUT_VOL_MINUS_6DB;
892 case T_AUDIO_OUTPUT_VOL_LEVEL_10:
893 return T_OUTPUT_VOL_MINUS_3DB;
894 case T_AUDIO_OUTPUT_VOL_LEVEL_11:
895 return T_OUTPUT_VOL_0DB;
896 default:
897 return T_OUTPUT_VOL_0DB;
898 }
899}
900
901static int input_vol_conversion(int vol)
902{
903 switch(vol) {
904 case T_AUDIO_INPUT_VOL_LEVEL_0:
905 return T_INPUT_VOL_MINUS_96DB;
906 case T_AUDIO_INPUT_VOL_LEVEL_1:
907 return T_INPUT_VOL_MINUS_30DB;
908 case T_AUDIO_INPUT_VOL_LEVEL_2:
909 return T_INPUT_VOL_MINUS_25DB;
910 case T_AUDIO_INPUT_VOL_LEVEL_3:
911 return T_INPUT_VOL_MINUS_20DB;
912 case T_AUDIO_INPUT_VOL_LEVEL_4:
913 return T_INPUT_VOL_MINUS_15DB;
914 case T_AUDIO_INPUT_VOL_LEVEL_5:
915 return T_INPUT_VOL_MINUS_10DB;
916 case T_AUDIO_INPUT_VOL_LEVEL_6:
917 return T_INPUT_VOL_MINUS_7DB;
918 case T_AUDIO_INPUT_VOL_LEVEL_7:
919 return T_INPUT_VOL_MINUS_4DB;
920 case T_AUDIO_INPUT_VOL_LEVEL_8:
921 return T_INPUT_VOL_MINUS_3DB;
922 case T_AUDIO_INPUT_VOL_LEVEL_9:
923 return T_INPUT_VOL_MINUS_2DB;
924 case T_AUDIO_INPUT_VOL_LEVEL_10:
925 return T_INPUT_VOL_MINUS_1DB;
926 case T_AUDIO_INPUT_VOL_LEVEL_11:
927 return T_INPUT_VOL_0DB;
928 default:
929 return T_INPUT_VOL_MINUS_30DB;
930 }
931}
932
933#endif
934
935//static struct audio_para_conf nxp_voice_vol = {"voice processing path Volume",{"3"}}; //(range 0->5)
936
937static void mix_set_value_wrap(struct mixer *mixer, const char *control, char **values)
938{
939 struct mixer_ctl *ctl;
940 enum mixer_ctl_type type;
941 unsigned int num_ctl_values;
942 unsigned int i;
943
944 if (isdigit(control[0]))
945 ctl = mixer_get_ctl(mixer, atoi(control));
946 else
947 ctl = mixer_get_ctl_by_name(mixer, control);
948
949 if (!ctl) {
950 fprintf(stderr, "Invalid mixer control\n");
951 return;
952 }
953
954 type = mixer_ctl_get_type(ctl);
955 num_ctl_values = mixer_ctl_get_num_values(ctl);
956
957 if (isdigit(values[0][0])) {
958
959 for (i = 0; i < num_ctl_values; i++) {
960 if (mixer_ctl_set_value(ctl, i, atoi(values[i]))) {
961 fprintf(stderr, "Error: invalid value for index %d\n", i);
962 return;
963 }
964 }
965
966 } else {
967 if (type == MIXER_CTL_TYPE_ENUM) {
968 /*if (num_values != 1) {
969 fprintf(stderr, "Enclose strings in quotes and try again\n");
970 return;
971 }*/
972 if (mixer_ctl_set_enum_by_string(ctl, values[0]))
973 fprintf(stderr, "Error: invalid enum value\n");
974 } else {
975 fprintf(stderr, "Error: only enum types can be set with strings\n");
976 }
977 }
978}
979
980#ifdef _CPE_AUDIO_PRJ
981int mix_set_output_path(struct mixer *mixer, int path)
982{
983
984 return 0;
985}
986
987int mix_set_input_path(struct mixer *mixer, int path)
988{
989
990
991 return 0;
992}
993
994int mix_set_input_vol(struct mixer *mixer, int volume)
995{
996
997
998 return 0;
999}
1000
1001int mix_set_output_vol(struct mixer *mixer, int volume)
1002{
1003
1004
1005 return 0;
1006}
1007
1008int mix_set_output_mute(struct mixer *mixer, bool enable)
1009{
1010
1011
1012 return 0;
1013}
1014
1015int mix_set_input_mute(struct mixer *mixer, bool enable)
1016{
1017
1018
1019 return 0;
1020}
1021
1022int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff)
1023{
1024
1025 return 0;
1026}
1027
1028
1029int mix_set_voice_vol(struct mixer *mixer, int volume)
1030{
1031
1032
1033 return 0;
1034}
1035
1036int mix_set_voice_mute(struct mixer *mixer, bool enable)
1037{
1038
1039
1040 return 0;
1041}
1042
1043int mix_set_voice_path(struct mixer *mixer, int path)
1044{
1045 int i;
1046
1047
1048 return 0;
1049}
1050
1051
1052int mix_set_in_call_tone(struct mixer *mixer, int tontype)
1053{
1054
1055
1056 return 0;
1057}
1058
1059int mix_set_default_param(struct mixer *mixer)
1060{
1061
1062 return 0;
1063}
1064#else
1065int mix_set_output_path(struct mixer *mixer, int path)
1066{
1067 int i;
1068 for (i = 0; i < ARRAY_SIZE(common_out_para_audio); i++) {
1069 mix_set_value_wrap(mixer, common_out_para_audio[i].control, common_out_para_audio[i].values);
1070 }
1071 switch (path) {
1072 case T_OUTPUT_RECEIVER:
1073 for (i = 0; i < ARRAY_SIZE(hp_outpath_para_audio); i++) {
1074 mix_set_value_wrap(mixer, hp_outpath_para_audio[i].control, hp_outpath_para_audio[i].values);
1075 }
1076 break;
1077 case T_OUTPUT_SPEAKER:
1078 for (i = 0; i < ARRAY_SIZE(spk_outpath_para_audio); i++) {
1079 mix_set_value_wrap(mixer, spk_outpath_para_audio[i].control, spk_outpath_para_audio[i].values);
1080 }
1081 break;
1082 default:
1083 break;
1084 }
1085
1086 return 0;
1087}
1088
1089int mix_set_input_path(struct mixer *mixer, int path)
1090{
1091 int i;
1092 for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) {
1093 mix_set_value_wrap(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values);
1094 }
1095 switch (path) {
1096 case T_INPUT_MICLP:
1097 for (i = 0; i < ARRAY_SIZE(main_mic_inpath_para_audio); i++) {
1098 mix_set_value_wrap(mixer, main_mic_inpath_para_audio[i].control, main_mic_inpath_para_audio[i].values);
1099 }
1100 break;
1101 case T_INPUT_MICRP:
1102 for (i = 0; i < ARRAY_SIZE(aux_mic_inpath_para_audio); i++) {
1103 mix_set_value_wrap(mixer, aux_mic_inpath_para_audio[i].control, aux_mic_inpath_para_audio[i].values);
1104 }
1105 break;
1106 default:
1107 break;
1108 }
1109
1110 return 0;
1111}
1112
1113int mix_set_input_vol(struct mixer *mixer, int volume)
1114{
1115 struct mixer_ctl *ctl;
1116 char *name = input_adc_vol.control;
1117 int num_values, i;
1118 int vol = input_vol_conversion(volume);
1119
1120 ctl = mixer_get_ctl_by_name(mixer, name);
1121 if (!ctl) {
1122 fprintf(stderr, "Invalid mixer control\n");
1123 return -1;
1124 }
1125
1126 num_values = mixer_ctl_get_num_values(ctl);
1127
1128 for (i = 0; i < num_values; i++) {
1129 mixer_ctl_set_value(ctl, i, vol);
1130 }
1131
1132 return 0;
1133}
1134
1135int mix_set_output_vol(struct mixer *mixer, int volume)
1136{
1137 struct mixer_ctl *ctl;
1138 char *name = output_dac_vol.control;
1139 int num_values, i;
1140
1141 int vol = output_vol_conversion(volume);
1142
1143 ctl = mixer_get_ctl_by_name(mixer, name);
1144 if (!ctl) {
1145 fprintf(stderr, "Invalid mixer control\n");
1146 return -1;
1147 }
1148
1149 num_values = mixer_ctl_get_num_values(ctl);
1150
1151 for (i = 0; i < num_values; i++) {
1152 mixer_ctl_set_value(ctl, i, vol);
1153 }
1154
1155 return 0;
1156}
1157
1158int mix_set_output_mute(struct mixer *mixer, bool enable)
1159{
1160 struct mixer_ctl *ctl;
1161 char *name = dac_mute.control;
1162 int num_values, i;
1163
1164 ctl = mixer_get_ctl_by_name(mixer, name);
1165 if (!ctl) {
1166 fprintf(stderr, "Invalid mixer control\n");
1167 return -1;
1168 }
1169
1170 num_values = mixer_ctl_get_num_values(ctl);
1171
1172 for (i = 0; i < num_values; i++) {
1173 mixer_ctl_set_value(ctl, i, enable);
1174 }
1175
1176 return 0;
1177}
1178
1179int mix_set_input_mute(struct mixer *mixer, bool enable)
1180{
1181 struct mixer_ctl *ctl;
1182 char *name = adc_mute.control;
1183 ctl = mixer_get_ctl_by_name(mixer, name);
1184 int num_values, i;
1185
1186 if (!ctl) {
1187 fprintf(stderr, "Invalid mixer control\n");
1188 return -1;
1189 }
1190
1191 num_values = mixer_ctl_get_num_values(ctl);
1192
1193 for (i = 0; i < num_values; i++) {
1194 mixer_ctl_set_value(ctl, 0, enable);
1195 }
1196
1197 return 0;
1198}
1199
1200int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff)
1201{
1202 struct mixer_ctl *ctl;
1203 struct audio_para_conf *path_para;
1204 int i, j, num_values, size;
1205 switch(path) {
1206 case T_OUTPUT_RECEIVER:
1207 size = ARRAY_SIZE(rcv_path_onoff);
1208 path_para = rcv_path_onoff;
1209 break;
1210 case T_OUTPUT_SPEAKER:
1211 size = ARRAY_SIZE(spk_path_onoff);
1212 path_para = spk_path_onoff;
1213 break;
1214 case T_OUTPUT_HEADSET:
1215 size = ARRAY_SIZE(earp_path_onoff);
1216 path_para = earp_path_onoff;
1217 break;
1218 default:
1219 return -1;
1220 }
1221
1222 for (i = 0; i < size; i++) {
1223 ctl = mixer_get_ctl_by_name(mixer, path_para[i].control);
1224 num_values = mixer_ctl_get_num_values(ctl);
1225
1226 for (j = 0; j < num_values; j++) {
1227 mixer_ctl_set_value(ctl, j, onoff);
1228 }
1229
1230// mix_set_value_wrap(mixer, spk_path_onoff[i].control, spk_path_onoff[i].values);
1231 }
1232
1233 return 0;
1234}
1235
1236
1237int mix_set_voice_vol(struct mixer *mixer, int volume)
1238{
1239 struct mixer_ctl *ctl;
1240 char name[] = "voice processing path Volume";
1241 ctl = mixer_get_ctl_by_name(mixer, name);
1242 if (!ctl) {
1243 fprintf(stderr, "Invalid mixer control\n");
1244 return -1;
1245 }
1246
1247 mixer_ctl_set_value(ctl, 0, volume);
1248
1249 return 0;
1250}
1251
1252int mix_set_voice_mute(struct mixer *mixer, bool enable)
1253{
1254 struct mixer_ctl *ctl;
1255 char name[] = "voice uplink mute";
1256 ctl = mixer_get_ctl_by_name(mixer, name);
1257 if (!ctl) {
1258 fprintf(stderr, "Invalid mixer control\n");
1259 return -1;
1260 }
1261
1262 mixer_ctl_set_value(ctl, 0, enable);
1263
1264 return 0;
1265}
1266
1267int mix_set_voice_path(struct mixer *mixer, int path)
1268{
1269 int i;
1270/*
1271 for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) {
1272 tinymix_set_value_test(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values);
1273 }
1274
1275 for(i = 0;i<ARRAY_SIZE(common_out_para_audio);i++)
1276 {
1277 tinymix_set_value_test(mixer,common_out_para_audio[i].control,common_out_para_audio[i].values);
1278 }
1279*/
1280 switch (path) {
1281 case T_OUTPUT_RECEIVER:
1282 for (i = 0; i < ARRAY_SIZE(handset_inoutpath_para_voice); i++) {
1283 mix_set_value_wrap(mixer, handset_inoutpath_para_voice[i].control, handset_inoutpath_para_voice[i].values);
1284 }
1285 break;
1286 case T_OUTPUT_SPEAKER:
1287 for (i = 0; i < ARRAY_SIZE(spk_inoutpath_para_voice); i++) {
1288 mix_set_value_wrap(mixer, spk_inoutpath_para_voice[i].control, spk_inoutpath_para_voice[i].values);
1289 }
1290 break;
1291 case T_OUTPUT_HEADSET:
1292 for (i = 0; i < ARRAY_SIZE(headset_inoutpath_para_voice); i++) {
1293 mix_set_value_wrap(mixer, headset_inoutpath_para_voice[i].control, headset_inoutpath_para_voice[i].values);
1294 }
1295 default:
1296 break;
1297 }
1298
1299 return 0;
1300}
1301
1302
1303int mix_set_in_call_tone(struct mixer *mixer, int tontype)
1304{
1305 struct mixer_ctl *ctl;
1306 char name[] = "voice tone sel";
1307 ctl = mixer_get_ctl_by_name(mixer, name);
1308 if (!ctl) {
1309 fprintf(stderr, "Invalid mixer control\n");
1310 return -1;
1311 }
1312
1313 mixer_ctl_set_value(ctl, 0, tontype);
1314
1315 return 0;
1316}
1317
1318int mix_set_default_param(struct mixer *mixer)
1319{
1320 int i;
1321 for (i = 0; i < ARRAY_SIZE(init_default_para); i++) {
1322 mix_set_value_wrap(mixer, init_default_para[i].control, init_default_para[i].values);
1323 }
1324
1325 return 0;
1326}
1327#endif