blob: 311ceca39b7e7be26308488d06f2e8cc2ea30fe0 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -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
xf.libdd93d52023-05-12 07:10:14 -0700933#elif defined _ALSA_CODEC_IN_CAP
934
935static struct audio_para_conf init_default_para[] = {
936};
937
938static struct audio_para_conf common_out_para_audio[] = {
939
940};
941
942
943
944static struct audio_para_conf common_in_para_audio[] = {
945};
946
947static struct audio_para_conf hp_outpath_para_audio[] = {
948};
949
950
951static struct audio_para_conf spk_outpath_para_audio[] = {
952};
953
954static struct audio_para_conf main_mic_inpath_para_audio[] = {
955};
956
957static struct audio_para_conf aux_mic_inpath_para_audio[] = {
958};
959
960static struct audio_para_conf handset_inoutpath_para_voice[] = {
961 {"voice processing path select", {"handset"}}, // handset speak headset bluetooth
962};
963
964static struct audio_para_conf headset_inoutpath_para_voice[] = {
965 {"voice processing path select", {"headset"}}, // handset speak headset bluetooth
966};
967
968static struct audio_para_conf spk_inoutpath_para_voice[] = {
969 {"voice processing path select", {"speak"}}, // handset speak headset bluetooth
970};
971
972static struct audio_para_conf output_dac_vol = {};
973
974static struct audio_para_conf input_adc_vol = {};
975
976static struct audio_para_conf dac_mute = {};
977static struct audio_para_conf adc_mute = {};
978
979static struct audio_para_conf spk_path_onoff[] = {
980
981};
982static struct audio_para_conf rcv_path_onoff[] = {
983
984};
985static struct audio_para_conf earp_path_onoff[] = {
986
987};
988static int output_vol_conversion(int vol)
989{
990
991 return 24;
992}
993
994static int input_vol_conversion(int vol)
995{
996
997 return 24;
998
999}
1000
1001#else
1002
1003static struct audio_para_conf init_default_para[] = {
1004};
1005
1006static struct audio_para_conf common_out_para_audio[] = {
1007
1008};
1009
1010
1011
1012static struct audio_para_conf common_in_para_audio[] = {
1013};
1014
1015static struct audio_para_conf hp_outpath_para_audio[] = {
1016};
1017
1018
1019static struct audio_para_conf spk_outpath_para_audio[] = {
1020};
1021
1022static struct audio_para_conf main_mic_inpath_para_audio[] = {
1023};
1024
1025static struct audio_para_conf aux_mic_inpath_para_audio[] = {
1026};
1027
1028static struct audio_para_conf handset_inoutpath_para_voice[] = {
1029
1030};
1031
1032static struct audio_para_conf headset_inoutpath_para_voice[] = {
1033};
1034
1035static struct audio_para_conf spk_inoutpath_para_voice[] = {
1036};
1037
1038static struct audio_para_conf output_dac_vol = {};
1039
1040static struct audio_para_conf input_adc_vol = {};
1041
1042static struct audio_para_conf dac_mute = {};
1043static struct audio_para_conf adc_mute = {};
1044
1045static struct audio_para_conf spk_path_onoff[] = {
1046
1047};
1048static struct audio_para_conf rcv_path_onoff[] = {
1049
1050};
1051static struct audio_para_conf earp_path_onoff[] = {
1052
1053};
1054static int output_vol_conversion(int vol)
1055{
1056
1057 return 24;
1058}
1059
1060static int input_vol_conversion(int vol)
1061{
1062
1063 return 24;
1064
1065}
1066
1067
1068
1069
lh9ed821d2023-04-07 01:36:19 -07001070#endif
1071
1072//static struct audio_para_conf nxp_voice_vol = {"voice processing path Volume",{"3"}}; //(range 0->5)
1073
1074static void mix_set_value_wrap(struct mixer *mixer, const char *control, char **values)
1075{
1076 struct mixer_ctl *ctl;
1077 enum mixer_ctl_type type;
1078 unsigned int num_ctl_values;
1079 unsigned int i;
1080
1081 if (isdigit(control[0]))
1082 ctl = mixer_get_ctl(mixer, atoi(control));
1083 else
1084 ctl = mixer_get_ctl_by_name(mixer, control);
1085
1086 if (!ctl) {
xf.libdd93d52023-05-12 07:10:14 -07001087 fprintf(stderr, "Invalid mixer control(%s)\n",control);
lh9ed821d2023-04-07 01:36:19 -07001088 return;
1089 }
1090
1091 type = mixer_ctl_get_type(ctl);
1092 num_ctl_values = mixer_ctl_get_num_values(ctl);
1093
1094 if (isdigit(values[0][0])) {
1095
1096 for (i = 0; i < num_ctl_values; i++) {
1097 if (mixer_ctl_set_value(ctl, i, atoi(values[i]))) {
1098 fprintf(stderr, "Error: invalid value for index %d\n", i);
1099 return;
1100 }
1101 }
1102
1103 } else {
1104 if (type == MIXER_CTL_TYPE_ENUM) {
1105 /*if (num_values != 1) {
1106 fprintf(stderr, "Enclose strings in quotes and try again\n");
1107 return;
1108 }*/
1109 if (mixer_ctl_set_enum_by_string(ctl, values[0]))
1110 fprintf(stderr, "Error: invalid enum value\n");
1111 } else {
1112 fprintf(stderr, "Error: only enum types can be set with strings\n");
1113 }
1114 }
1115}
1116
xf.libdd93d52023-05-12 07:10:14 -07001117static void mix_get_value_wrap(struct mixer *mixer, const char *control, int *values)
1118{
1119 struct mixer_ctl *ctl;
1120 enum mixer_ctl_type type;
1121 unsigned int num_ctl_values;
1122 unsigned int i;
1123 int val;
1124
1125 if (isdigit(control[0]))
1126 ctl = mixer_get_ctl(mixer, atoi(control));
1127 else
1128 ctl = mixer_get_ctl_by_name(mixer, control);
1129
1130 if (!ctl) {
1131 fprintf(stderr, "Invalid mixer control(%s)\n",control);
1132 return;
1133 }
1134
1135 type = mixer_ctl_get_type(ctl);
1136 num_ctl_values = mixer_ctl_get_num_values(ctl);
1137
1138
1139 for (i = 0; i < num_ctl_values; i++) {
1140 val = mixer_ctl_get_value(ctl, i);
1141 if (val == -EINVAL) {
1142 fprintf(stderr, "Error: invalid value for index %d\n", i);
1143 return;
1144 }
1145 *(values+i) = val;
1146 }
1147
1148}
lh9ed821d2023-04-07 01:36:19 -07001149#ifdef _CPE_AUDIO_PRJ
1150int mix_set_output_path(struct mixer *mixer, int path)
1151{
1152
1153 return 0;
1154}
1155
1156int mix_set_input_path(struct mixer *mixer, int path)
1157{
1158
1159
1160 return 0;
1161}
1162
1163int mix_set_input_vol(struct mixer *mixer, int volume)
1164{
1165
1166
1167 return 0;
1168}
1169
1170int mix_set_output_vol(struct mixer *mixer, int volume)
1171{
1172
1173
1174 return 0;
1175}
1176
1177int mix_set_output_mute(struct mixer *mixer, bool enable)
1178{
1179
1180
1181 return 0;
1182}
1183
1184int mix_set_input_mute(struct mixer *mixer, bool enable)
1185{
1186
1187
1188 return 0;
1189}
1190
1191int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff)
1192{
1193
1194 return 0;
1195}
1196
1197
1198int mix_set_voice_vol(struct mixer *mixer, int volume)
1199{
1200
1201
1202 return 0;
1203}
xf.libdd93d52023-05-12 07:10:14 -07001204int mix_get_voice_vol(struct mixer *mixer, int *volume)
1205{
1206
1207 return 0;
1208}
1209
1210
1211
1212int mix_set_tx_voice_vol(struct mixer *mixer, int volume)
1213{
1214
1215 return 0;
1216}
1217
1218int mix_get_tx_voice_vol(struct mixer *mixer, int *volume)
1219{
1220
1221 return 0;
1222}
1223
lh9ed821d2023-04-07 01:36:19 -07001224
1225int mix_set_voice_mute(struct mixer *mixer, bool enable)
1226{
1227
1228
1229 return 0;
1230}
1231
xf.libdd93d52023-05-12 07:10:14 -07001232int mix_get_voice_mute(struct mixer *mixer, bool *enable)
1233{
1234
1235 return 0;
1236}
1237
1238
1239int mix_set_rx_voice_mute(struct mixer *mixer, bool enable)
1240{
1241
1242
1243 return 0;
1244}
1245
1246int mix_get_rx_voice_mute(struct mixer *mixer, bool *enable)
1247{
1248
1249 return 0;
1250}
1251
1252
1253
1254int mix_set_vp_path(struct mixer *mixer, int path)
1255{
1256
1257 return 0;
1258}
1259
1260int mix_get_vp_path(struct mixer *mixer, int *path)
1261{
1262
1263 return 0;
1264}
1265
1266
lh9ed821d2023-04-07 01:36:19 -07001267int mix_set_voice_path(struct mixer *mixer, int path)
1268{
1269 int i;
1270
1271
1272 return 0;
1273}
1274
1275
1276int mix_set_in_call_tone(struct mixer *mixer, int tontype)
1277{
1278
1279
1280 return 0;
1281}
1282
1283int mix_set_default_param(struct mixer *mixer)
1284{
1285
1286 return 0;
1287}
xf.libdd93d52023-05-12 07:10:14 -07001288int set_voice_device_mode(int dev_mode)
1289{
1290 return 0;
1291}
lh758261d2023-07-13 05:52:04 -07001292int mix_set_vploop(struct mixer *mixer, int path)
1293{
1294
1295 return 0;
1296}
1297int mix_get_vploop(struct mixer *mixer, int *state)
1298{
1299 return 0;
1300}
1301
1302
lh9ed821d2023-04-07 01:36:19 -07001303#else
1304int mix_set_output_path(struct mixer *mixer, int path)
1305{
1306 int i;
1307 for (i = 0; i < ARRAY_SIZE(common_out_para_audio); i++) {
1308 mix_set_value_wrap(mixer, common_out_para_audio[i].control, common_out_para_audio[i].values);
1309 }
1310 switch (path) {
1311 case T_OUTPUT_RECEIVER:
1312 for (i = 0; i < ARRAY_SIZE(hp_outpath_para_audio); i++) {
1313 mix_set_value_wrap(mixer, hp_outpath_para_audio[i].control, hp_outpath_para_audio[i].values);
1314 }
1315 break;
1316 case T_OUTPUT_SPEAKER:
1317 for (i = 0; i < ARRAY_SIZE(spk_outpath_para_audio); i++) {
1318 mix_set_value_wrap(mixer, spk_outpath_para_audio[i].control, spk_outpath_para_audio[i].values);
1319 }
1320 break;
1321 default:
1322 break;
1323 }
1324
1325 return 0;
1326}
1327
1328int mix_set_input_path(struct mixer *mixer, int path)
1329{
1330 int i;
1331 for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) {
1332 mix_set_value_wrap(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values);
1333 }
1334 switch (path) {
1335 case T_INPUT_MICLP:
1336 for (i = 0; i < ARRAY_SIZE(main_mic_inpath_para_audio); i++) {
1337 mix_set_value_wrap(mixer, main_mic_inpath_para_audio[i].control, main_mic_inpath_para_audio[i].values);
1338 }
1339 break;
1340 case T_INPUT_MICRP:
1341 for (i = 0; i < ARRAY_SIZE(aux_mic_inpath_para_audio); i++) {
1342 mix_set_value_wrap(mixer, aux_mic_inpath_para_audio[i].control, aux_mic_inpath_para_audio[i].values);
1343 }
1344 break;
1345 default:
1346 break;
1347 }
1348
1349 return 0;
1350}
1351
1352int mix_set_input_vol(struct mixer *mixer, int volume)
1353{
1354 struct mixer_ctl *ctl;
1355 char *name = input_adc_vol.control;
1356 int num_values, i;
1357 int vol = input_vol_conversion(volume);
1358
1359 ctl = mixer_get_ctl_by_name(mixer, name);
1360 if (!ctl) {
1361 fprintf(stderr, "Invalid mixer control\n");
1362 return -1;
1363 }
1364
1365 num_values = mixer_ctl_get_num_values(ctl);
1366
1367 for (i = 0; i < num_values; i++) {
1368 mixer_ctl_set_value(ctl, i, vol);
1369 }
1370
1371 return 0;
1372}
1373
1374int mix_set_output_vol(struct mixer *mixer, int volume)
1375{
1376 struct mixer_ctl *ctl;
1377 char *name = output_dac_vol.control;
1378 int num_values, i;
1379
1380 int vol = output_vol_conversion(volume);
1381
1382 ctl = mixer_get_ctl_by_name(mixer, name);
1383 if (!ctl) {
1384 fprintf(stderr, "Invalid mixer control\n");
1385 return -1;
1386 }
1387
1388 num_values = mixer_ctl_get_num_values(ctl);
1389
1390 for (i = 0; i < num_values; i++) {
1391 mixer_ctl_set_value(ctl, i, vol);
1392 }
1393
1394 return 0;
1395}
1396
1397int mix_set_output_mute(struct mixer *mixer, bool enable)
1398{
1399 struct mixer_ctl *ctl;
1400 char *name = dac_mute.control;
1401 int num_values, i;
1402
1403 ctl = mixer_get_ctl_by_name(mixer, name);
1404 if (!ctl) {
1405 fprintf(stderr, "Invalid mixer control\n");
1406 return -1;
1407 }
1408
1409 num_values = mixer_ctl_get_num_values(ctl);
1410
1411 for (i = 0; i < num_values; i++) {
1412 mixer_ctl_set_value(ctl, i, enable);
1413 }
1414
1415 return 0;
1416}
1417
1418int mix_set_input_mute(struct mixer *mixer, bool enable)
1419{
1420 struct mixer_ctl *ctl;
1421 char *name = adc_mute.control;
1422 ctl = mixer_get_ctl_by_name(mixer, name);
1423 int num_values, i;
1424
1425 if (!ctl) {
1426 fprintf(stderr, "Invalid mixer control\n");
1427 return -1;
1428 }
1429
1430 num_values = mixer_ctl_get_num_values(ctl);
1431
1432 for (i = 0; i < num_values; i++) {
1433 mixer_ctl_set_value(ctl, 0, enable);
1434 }
1435
1436 return 0;
1437}
1438
1439int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff)
1440{
1441 struct mixer_ctl *ctl;
1442 struct audio_para_conf *path_para;
1443 int i, j, num_values, size;
1444 switch(path) {
1445 case T_OUTPUT_RECEIVER:
1446 size = ARRAY_SIZE(rcv_path_onoff);
1447 path_para = rcv_path_onoff;
1448 break;
1449 case T_OUTPUT_SPEAKER:
1450 size = ARRAY_SIZE(spk_path_onoff);
1451 path_para = spk_path_onoff;
1452 break;
1453 case T_OUTPUT_HEADSET:
1454 size = ARRAY_SIZE(earp_path_onoff);
1455 path_para = earp_path_onoff;
1456 break;
1457 default:
1458 return -1;
1459 }
1460
1461 for (i = 0; i < size; i++) {
1462 ctl = mixer_get_ctl_by_name(mixer, path_para[i].control);
1463 num_values = mixer_ctl_get_num_values(ctl);
1464
1465 for (j = 0; j < num_values; j++) {
1466 mixer_ctl_set_value(ctl, j, onoff);
1467 }
1468
1469// mix_set_value_wrap(mixer, spk_path_onoff[i].control, spk_path_onoff[i].values);
1470 }
1471
1472 return 0;
1473}
1474
1475
1476int mix_set_voice_vol(struct mixer *mixer, int volume)
1477{
1478 struct mixer_ctl *ctl;
1479 char name[] = "voice processing path Volume";
1480 ctl = mixer_get_ctl_by_name(mixer, name);
1481 if (!ctl) {
1482 fprintf(stderr, "Invalid mixer control\n");
1483 return -1;
1484 }
1485
1486 mixer_ctl_set_value(ctl, 0, volume);
1487
1488 return 0;
1489}
1490
xf.libdd93d52023-05-12 07:10:14 -07001491int mix_get_voice_vol(struct mixer *mixer, int *volume)
1492{
1493 struct mixer_ctl *ctl;
1494 int val;
1495
1496 printf("%s: start !\n",__func__);
1497 char name[] = "voice processing path Volume";
1498 ctl = mixer_get_ctl_by_name(mixer, name);
1499 if (!ctl) {
1500 fprintf(stderr, "Invalid mixer control\n");
1501 return -1;
1502 }
1503
1504 val = mixer_ctl_get_value(ctl, 0);
1505 if((val < 0)||(val > 11)){
1506 fprintf(stderr, "Invalid val=%d\n",val);
1507 return -2;
1508 }
1509 *volume = val;
1510 return 0;
1511}
1512
1513int mix_set_tx_voice_vol(struct mixer *mixer, int volume)
1514{
1515 struct mixer_ctl *ctl;
1516 char name[] = "voice processing tx path Volume";
1517 ctl = mixer_get_ctl_by_name(mixer, name);
1518 if (!ctl) {
1519 fprintf(stderr, "Invalid mixer control\n");
1520 return -1;
1521 }
1522
1523 mixer_ctl_set_value(ctl, 0, volume);
1524
1525 return 0;
1526}
1527
1528int mix_get_tx_voice_vol(struct mixer *mixer, int *volume)
1529{
1530 struct mixer_ctl *ctl;
1531 int val;
1532
1533 printf("%s: start !\n",__func__);
1534 char name[] = "voice processing tx path Volume";
1535 ctl = mixer_get_ctl_by_name(mixer, name);
1536 if (!ctl) {
1537 fprintf(stderr, "Invalid mixer control\n");
1538 return -1;
1539 }
1540
1541 val = mixer_ctl_get_value(ctl, 0);
1542 if((val < 0)||(val > 11)){
1543 fprintf(stderr, "Invalid val=%d\n",val);
1544 return -2;
1545 }
1546 *volume = val;
1547 return 0;
1548}
1549
1550
lh9ed821d2023-04-07 01:36:19 -07001551int mix_set_voice_mute(struct mixer *mixer, bool enable)
1552{
1553 struct mixer_ctl *ctl;
1554 char name[] = "voice uplink mute";
1555 ctl = mixer_get_ctl_by_name(mixer, name);
1556 if (!ctl) {
1557 fprintf(stderr, "Invalid mixer control\n");
1558 return -1;
1559 }
1560
1561 mixer_ctl_set_value(ctl, 0, enable);
1562
1563 return 0;
1564}
1565
xf.libdd93d52023-05-12 07:10:14 -07001566int mix_get_voice_mute(struct mixer *mixer, bool *enable)
1567{
1568 struct mixer_ctl *ctl;
1569 int val;
1570
1571 printf("%s: start !\n",__func__);
1572 char name[] = "voice uplink mute";
1573 ctl = mixer_get_ctl_by_name(mixer, name);
1574 if (!ctl) {
1575 fprintf(stderr, "Invalid mixer control\n");
1576 return -1;
1577 }
1578
1579 val = mixer_ctl_get_value(ctl, 0);
1580 if((val != 0)&&(val != 1)){
1581 fprintf(stderr, "Invalid val=%d\n",val);
1582 return -2;
1583 }
1584 *enable = val;
1585 return 0;
1586}
1587
1588
1589int mix_set_rx_voice_mute(struct mixer *mixer, bool enable)
1590{
1591 struct mixer_ctl *ctl;
1592 char name[] = "voice downlink mute";
1593 ctl = mixer_get_ctl_by_name(mixer, name);
1594 if (!ctl) {
1595 fprintf(stderr, "Invalid mixer control\n");
1596 return -1;
1597 }
1598
1599 mixer_ctl_set_value(ctl, 0, enable);
1600
1601 return 0;
1602}
1603
1604int mix_get_rx_voice_mute(struct mixer *mixer, bool *enable)
1605{
1606 struct mixer_ctl *ctl;
1607 int val;
1608
1609 printf("%s: start !\n",__func__);
1610 char name[] = "voice downlink mute";
1611 ctl = mixer_get_ctl_by_name(mixer, name);
1612 if (!ctl) {
1613 fprintf(stderr, "Invalid mixer control\n");
1614 return -1;
1615 }
1616
1617 val = mixer_ctl_get_value(ctl, 0);
1618 if((val != 0)&&(val != 1)){
1619 fprintf(stderr, "Invalid val=%d\n",val);
1620 return -2;
1621 }
1622 *enable = val;
1623 return 0;
1624}
1625
1626int mix_set_vp_path(struct mixer *mixer, int path)
1627{
1628 int ret = 0;
1629 unsigned int num_enums;
1630 struct mixer_ctl *ctl;
1631 char name[] = "voice processing path select";
1632 ctl = mixer_get_ctl_by_name(mixer, name);
1633 if (!ctl) {
1634 fprintf(stderr, "Invalid mixer control\n");
1635 return -1;
1636 }
1637 num_enums = mixer_ctl_get_num_enums(ctl);
1638
1639 if((path < 0)||(path >= num_enums)){
1640 fprintf(stderr, "Invalid val=%d\n",path);
1641 return -2;
1642 }
1643 ret = mixer_ctl_set_value(ctl, 0, path);
1644
1645 if (ret){
1646 fprintf(stderr, "Error: set value,ret=%d\n",ret);
1647 return -2;
1648 }
1649 return 0;
1650}
1651
1652
1653
1654
1655int mix_get_vp_path(struct mixer *mixer, int *path)
1656{
1657 struct mixer_ctl *ctl;
1658 int val;
1659 unsigned int num_enums;
1660
1661 printf("%s: start !\n",__func__);
1662 char name[] = "voice processing path select";
1663 ctl = mixer_get_ctl_by_name(mixer, name);
1664 if (!ctl) {
1665 fprintf(stderr, "Invalid mixer control\n");
1666 return -1;
1667 }
1668
1669 num_enums = mixer_ctl_get_num_enums(ctl);
1670
1671
1672 val = mixer_ctl_get_value(ctl, 0);
1673 if((val < 0)||(val >= num_enums)){
1674 fprintf(stderr, "Invalid val=%d\n",val);
1675 return -2;
1676 }
1677 printf("%s: val=%d !\n",__func__,val);
1678 *path = val;
1679 return 0;
1680}
1681
1682
1683
1684int mix_set_vp_path_st(struct mixer *mixer, char *path)
1685{
1686 struct mixer_ctl *ctl;
1687 char name[] = "voice processing path select";
1688 ctl = mixer_get_ctl_by_name(mixer, name);
1689 if (!ctl) {
1690 fprintf(stderr, "Invalid mixer control\n");
1691 return -1;
1692 }
1693
1694 //mixer_ctl_set_value(ctl, 0, path);
1695 if (mixer_ctl_set_enum_by_string(ctl, path))
1696 fprintf(stderr, "Error: invalid enum value\n");
1697 return 0;
1698}
1699
1700
1701
1702
1703int mix_get_vp_path_st(struct mixer *mixer, int *path)
1704{
1705 struct mixer_ctl *ctl;
1706 int val;
1707 unsigned int num_enums;
1708 unsigned int i;
1709 const char *string;
1710
1711 printf("%s: start !\n",__func__);
1712 char name[] = "voice processing path select";
1713 ctl = mixer_get_ctl_by_name(mixer, name);
1714 if (!ctl) {
1715 fprintf(stderr, "Invalid mixer control\n");
1716 return -1;
1717 }
1718
1719 num_enums = mixer_ctl_get_num_enums(ctl);
1720
1721
1722 val = mixer_ctl_get_value(ctl, 0);
1723 if((val < 0)||(val >= num_enums)){
1724 fprintf(stderr, "Invalid val=%d\n",val);
1725 return -2;
1726 }
1727 printf("%s: val=%d !\n",__func__,val);
1728
1729 string = mixer_ctl_get_enum_string(ctl, val);
1730
1731 if(string == NULL){
xf.li742dd022023-06-08 01:43:32 -07001732 fprintf(stderr, "err, string is NULL \n");
xf.libdd93d52023-05-12 07:10:14 -07001733 return -2;
1734 }
1735 printf("%s: string=%s !\n",__func__,string);
1736 path = string;
1737 return 0;
1738}
1739
1740
1741
lh9ed821d2023-04-07 01:36:19 -07001742int mix_set_voice_path(struct mixer *mixer, int path)
1743{
1744 int i;
1745/*
1746 for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) {
1747 tinymix_set_value_test(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values);
1748 }
1749
1750 for(i = 0;i<ARRAY_SIZE(common_out_para_audio);i++)
1751 {
1752 tinymix_set_value_test(mixer,common_out_para_audio[i].control,common_out_para_audio[i].values);
1753 }
1754*/
1755 switch (path) {
1756 case T_OUTPUT_RECEIVER:
1757 for (i = 0; i < ARRAY_SIZE(handset_inoutpath_para_voice); i++) {
1758 mix_set_value_wrap(mixer, handset_inoutpath_para_voice[i].control, handset_inoutpath_para_voice[i].values);
1759 }
1760 break;
1761 case T_OUTPUT_SPEAKER:
1762 for (i = 0; i < ARRAY_SIZE(spk_inoutpath_para_voice); i++) {
1763 mix_set_value_wrap(mixer, spk_inoutpath_para_voice[i].control, spk_inoutpath_para_voice[i].values);
1764 }
1765 break;
1766 case T_OUTPUT_HEADSET:
1767 for (i = 0; i < ARRAY_SIZE(headset_inoutpath_para_voice); i++) {
1768 mix_set_value_wrap(mixer, headset_inoutpath_para_voice[i].control, headset_inoutpath_para_voice[i].values);
1769 }
1770 default:
1771 break;
1772 }
1773
1774 return 0;
1775}
1776
1777
1778int mix_set_in_call_tone(struct mixer *mixer, int tontype)
1779{
1780 struct mixer_ctl *ctl;
1781 char name[] = "voice tone sel";
1782 ctl = mixer_get_ctl_by_name(mixer, name);
1783 if (!ctl) {
1784 fprintf(stderr, "Invalid mixer control\n");
1785 return -1;
1786 }
1787
1788 mixer_ctl_set_value(ctl, 0, tontype);
1789
1790 return 0;
1791}
1792
1793int mix_set_default_param(struct mixer *mixer)
1794{
1795 int i;
1796 for (i = 0; i < ARRAY_SIZE(init_default_para); i++) {
1797 mix_set_value_wrap(mixer, init_default_para[i].control, init_default_para[i].values);
1798 }
1799
1800 return 0;
1801}
xf.libdd93d52023-05-12 07:10:14 -07001802
1803int mix_get_voice_path(struct mixer *mixer, int *path)
1804{
1805
1806 mix_get_value_wrap(mixer, "audio path select", path);
1807
1808 return 0;
1809
1810}
1811#define VOCIE_SND_CARD_NUM 0
1812
1813
1814
1815//ÉèÖÃvoiceÒôƵÉ豸ģʽ dev_mode£ºhandset,speaker,headset 0 ±íʾ³É¹¦£¬ ÆäËü±íʾÓдíÎó
1816int set_voice_device_mode(int dev_mode)
1817{
1818
1819 struct mixer *voice_mixer = NULL;
1820 printf("%s: start dev_mode=%d!\n",__func__, dev_mode);
1821
1822 if ((dev_mode < T_OUTPUT_HANDSET ) ||(dev_mode > T_OUTPUT_HEADSET)){
1823 printf("%s: dev_mode not support, dev_mode=%d!\n",__func__, dev_mode);
1824 return -1;
1825 }
1826
1827 //open mixer dev for control
1828 voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
1829 if (!voice_mixer) {
1830 printf("voice_mixer open failed!\n");
1831 return -1;
1832 }
1833
1834 //config mixer dev
1835 mix_set_voice_path(voice_mixer, dev_mode);
1836
1837 //close mixer
1838 mixer_close(voice_mixer);
1839 voice_mixer = NULL;
1840
1841
1842 return 0;
1843
1844
1845}
1846
lh758261d2023-07-13 05:52:04 -07001847int mix_set_vploop(struct mixer *mixer, int path)
1848{
1849 struct mixer_ctl *ctl;
1850 char name[] = "vp loop";
1851 ctl = mixer_get_ctl_by_name(mixer, name);
1852 if (!ctl) {
1853 fprintf(stderr, "Invalid mixer control\n");
1854 return -1;
1855 }
1856
1857 mixer_ctl_set_value(ctl, 0, path);
1858
1859 return 0;
1860}
1861int mix_get_vploop(struct mixer *mixer, int *state)
1862{
1863
1864 mix_get_value_wrap(mixer, "vp loop", state);
1865
1866 return 0;
1867
1868}
xf.libdd93d52023-05-12 07:10:14 -07001869
1870
lh9ed821d2023-04-07 01:36:19 -07001871#endif