blob: 3ec6fe31261ae08db016123367b079740b2b3341 [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}
lh9ed821d2023-04-07 01:36:19 -07001292#else
1293int mix_set_output_path(struct mixer *mixer, int path)
1294{
1295 int i;
1296 for (i = 0; i < ARRAY_SIZE(common_out_para_audio); i++) {
1297 mix_set_value_wrap(mixer, common_out_para_audio[i].control, common_out_para_audio[i].values);
1298 }
1299 switch (path) {
1300 case T_OUTPUT_RECEIVER:
1301 for (i = 0; i < ARRAY_SIZE(hp_outpath_para_audio); i++) {
1302 mix_set_value_wrap(mixer, hp_outpath_para_audio[i].control, hp_outpath_para_audio[i].values);
1303 }
1304 break;
1305 case T_OUTPUT_SPEAKER:
1306 for (i = 0; i < ARRAY_SIZE(spk_outpath_para_audio); i++) {
1307 mix_set_value_wrap(mixer, spk_outpath_para_audio[i].control, spk_outpath_para_audio[i].values);
1308 }
1309 break;
1310 default:
1311 break;
1312 }
1313
1314 return 0;
1315}
1316
1317int mix_set_input_path(struct mixer *mixer, int path)
1318{
1319 int i;
1320 for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) {
1321 mix_set_value_wrap(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values);
1322 }
1323 switch (path) {
1324 case T_INPUT_MICLP:
1325 for (i = 0; i < ARRAY_SIZE(main_mic_inpath_para_audio); i++) {
1326 mix_set_value_wrap(mixer, main_mic_inpath_para_audio[i].control, main_mic_inpath_para_audio[i].values);
1327 }
1328 break;
1329 case T_INPUT_MICRP:
1330 for (i = 0; i < ARRAY_SIZE(aux_mic_inpath_para_audio); i++) {
1331 mix_set_value_wrap(mixer, aux_mic_inpath_para_audio[i].control, aux_mic_inpath_para_audio[i].values);
1332 }
1333 break;
1334 default:
1335 break;
1336 }
1337
1338 return 0;
1339}
1340
1341int mix_set_input_vol(struct mixer *mixer, int volume)
1342{
1343 struct mixer_ctl *ctl;
1344 char *name = input_adc_vol.control;
1345 int num_values, i;
1346 int vol = input_vol_conversion(volume);
1347
1348 ctl = mixer_get_ctl_by_name(mixer, name);
1349 if (!ctl) {
1350 fprintf(stderr, "Invalid mixer control\n");
1351 return -1;
1352 }
1353
1354 num_values = mixer_ctl_get_num_values(ctl);
1355
1356 for (i = 0; i < num_values; i++) {
1357 mixer_ctl_set_value(ctl, i, vol);
1358 }
1359
1360 return 0;
1361}
1362
1363int mix_set_output_vol(struct mixer *mixer, int volume)
1364{
1365 struct mixer_ctl *ctl;
1366 char *name = output_dac_vol.control;
1367 int num_values, i;
1368
1369 int vol = output_vol_conversion(volume);
1370
1371 ctl = mixer_get_ctl_by_name(mixer, name);
1372 if (!ctl) {
1373 fprintf(stderr, "Invalid mixer control\n");
1374 return -1;
1375 }
1376
1377 num_values = mixer_ctl_get_num_values(ctl);
1378
1379 for (i = 0; i < num_values; i++) {
1380 mixer_ctl_set_value(ctl, i, vol);
1381 }
1382
1383 return 0;
1384}
1385
1386int mix_set_output_mute(struct mixer *mixer, bool enable)
1387{
1388 struct mixer_ctl *ctl;
1389 char *name = dac_mute.control;
1390 int num_values, i;
1391
1392 ctl = mixer_get_ctl_by_name(mixer, name);
1393 if (!ctl) {
1394 fprintf(stderr, "Invalid mixer control\n");
1395 return -1;
1396 }
1397
1398 num_values = mixer_ctl_get_num_values(ctl);
1399
1400 for (i = 0; i < num_values; i++) {
1401 mixer_ctl_set_value(ctl, i, enable);
1402 }
1403
1404 return 0;
1405}
1406
1407int mix_set_input_mute(struct mixer *mixer, bool enable)
1408{
1409 struct mixer_ctl *ctl;
1410 char *name = adc_mute.control;
1411 ctl = mixer_get_ctl_by_name(mixer, name);
1412 int num_values, i;
1413
1414 if (!ctl) {
1415 fprintf(stderr, "Invalid mixer control\n");
1416 return -1;
1417 }
1418
1419 num_values = mixer_ctl_get_num_values(ctl);
1420
1421 for (i = 0; i < num_values; i++) {
1422 mixer_ctl_set_value(ctl, 0, enable);
1423 }
1424
1425 return 0;
1426}
1427
1428int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff)
1429{
1430 struct mixer_ctl *ctl;
1431 struct audio_para_conf *path_para;
1432 int i, j, num_values, size;
1433 switch(path) {
1434 case T_OUTPUT_RECEIVER:
1435 size = ARRAY_SIZE(rcv_path_onoff);
1436 path_para = rcv_path_onoff;
1437 break;
1438 case T_OUTPUT_SPEAKER:
1439 size = ARRAY_SIZE(spk_path_onoff);
1440 path_para = spk_path_onoff;
1441 break;
1442 case T_OUTPUT_HEADSET:
1443 size = ARRAY_SIZE(earp_path_onoff);
1444 path_para = earp_path_onoff;
1445 break;
1446 default:
1447 return -1;
1448 }
1449
1450 for (i = 0; i < size; i++) {
1451 ctl = mixer_get_ctl_by_name(mixer, path_para[i].control);
1452 num_values = mixer_ctl_get_num_values(ctl);
1453
1454 for (j = 0; j < num_values; j++) {
1455 mixer_ctl_set_value(ctl, j, onoff);
1456 }
1457
1458// mix_set_value_wrap(mixer, spk_path_onoff[i].control, spk_path_onoff[i].values);
1459 }
1460
1461 return 0;
1462}
1463
1464
1465int mix_set_voice_vol(struct mixer *mixer, int volume)
1466{
1467 struct mixer_ctl *ctl;
1468 char name[] = "voice processing path Volume";
1469 ctl = mixer_get_ctl_by_name(mixer, name);
1470 if (!ctl) {
1471 fprintf(stderr, "Invalid mixer control\n");
1472 return -1;
1473 }
1474
1475 mixer_ctl_set_value(ctl, 0, volume);
1476
1477 return 0;
1478}
1479
xf.libdd93d52023-05-12 07:10:14 -07001480int mix_get_voice_vol(struct mixer *mixer, int *volume)
1481{
1482 struct mixer_ctl *ctl;
1483 int val;
1484
1485 printf("%s: start !\n",__func__);
1486 char name[] = "voice processing path Volume";
1487 ctl = mixer_get_ctl_by_name(mixer, name);
1488 if (!ctl) {
1489 fprintf(stderr, "Invalid mixer control\n");
1490 return -1;
1491 }
1492
1493 val = mixer_ctl_get_value(ctl, 0);
1494 if((val < 0)||(val > 11)){
1495 fprintf(stderr, "Invalid val=%d\n",val);
1496 return -2;
1497 }
1498 *volume = val;
1499 return 0;
1500}
1501
1502int mix_set_tx_voice_vol(struct mixer *mixer, int volume)
1503{
1504 struct mixer_ctl *ctl;
1505 char name[] = "voice processing tx path Volume";
1506 ctl = mixer_get_ctl_by_name(mixer, name);
1507 if (!ctl) {
1508 fprintf(stderr, "Invalid mixer control\n");
1509 return -1;
1510 }
1511
1512 mixer_ctl_set_value(ctl, 0, volume);
1513
1514 return 0;
1515}
1516
1517int mix_get_tx_voice_vol(struct mixer *mixer, int *volume)
1518{
1519 struct mixer_ctl *ctl;
1520 int val;
1521
1522 printf("%s: start !\n",__func__);
1523 char name[] = "voice processing tx path Volume";
1524 ctl = mixer_get_ctl_by_name(mixer, name);
1525 if (!ctl) {
1526 fprintf(stderr, "Invalid mixer control\n");
1527 return -1;
1528 }
1529
1530 val = mixer_ctl_get_value(ctl, 0);
1531 if((val < 0)||(val > 11)){
1532 fprintf(stderr, "Invalid val=%d\n",val);
1533 return -2;
1534 }
1535 *volume = val;
1536 return 0;
1537}
1538
1539
lh9ed821d2023-04-07 01:36:19 -07001540int mix_set_voice_mute(struct mixer *mixer, bool enable)
1541{
1542 struct mixer_ctl *ctl;
1543 char name[] = "voice uplink mute";
1544 ctl = mixer_get_ctl_by_name(mixer, name);
1545 if (!ctl) {
1546 fprintf(stderr, "Invalid mixer control\n");
1547 return -1;
1548 }
1549
1550 mixer_ctl_set_value(ctl, 0, enable);
1551
1552 return 0;
1553}
1554
xf.libdd93d52023-05-12 07:10:14 -07001555int mix_get_voice_mute(struct mixer *mixer, bool *enable)
1556{
1557 struct mixer_ctl *ctl;
1558 int val;
1559
1560 printf("%s: start !\n",__func__);
1561 char name[] = "voice uplink mute";
1562 ctl = mixer_get_ctl_by_name(mixer, name);
1563 if (!ctl) {
1564 fprintf(stderr, "Invalid mixer control\n");
1565 return -1;
1566 }
1567
1568 val = mixer_ctl_get_value(ctl, 0);
1569 if((val != 0)&&(val != 1)){
1570 fprintf(stderr, "Invalid val=%d\n",val);
1571 return -2;
1572 }
1573 *enable = val;
1574 return 0;
1575}
1576
1577
1578int mix_set_rx_voice_mute(struct mixer *mixer, bool enable)
1579{
1580 struct mixer_ctl *ctl;
1581 char name[] = "voice downlink mute";
1582 ctl = mixer_get_ctl_by_name(mixer, name);
1583 if (!ctl) {
1584 fprintf(stderr, "Invalid mixer control\n");
1585 return -1;
1586 }
1587
1588 mixer_ctl_set_value(ctl, 0, enable);
1589
1590 return 0;
1591}
1592
1593int mix_get_rx_voice_mute(struct mixer *mixer, bool *enable)
1594{
1595 struct mixer_ctl *ctl;
1596 int val;
1597
1598 printf("%s: start !\n",__func__);
1599 char name[] = "voice downlink mute";
1600 ctl = mixer_get_ctl_by_name(mixer, name);
1601 if (!ctl) {
1602 fprintf(stderr, "Invalid mixer control\n");
1603 return -1;
1604 }
1605
1606 val = mixer_ctl_get_value(ctl, 0);
1607 if((val != 0)&&(val != 1)){
1608 fprintf(stderr, "Invalid val=%d\n",val);
1609 return -2;
1610 }
1611 *enable = val;
1612 return 0;
1613}
1614
1615int mix_set_vp_path(struct mixer *mixer, int path)
1616{
1617 int ret = 0;
1618 unsigned int num_enums;
1619 struct mixer_ctl *ctl;
1620 char name[] = "voice processing path select";
1621 ctl = mixer_get_ctl_by_name(mixer, name);
1622 if (!ctl) {
1623 fprintf(stderr, "Invalid mixer control\n");
1624 return -1;
1625 }
1626 num_enums = mixer_ctl_get_num_enums(ctl);
1627
1628 if((path < 0)||(path >= num_enums)){
1629 fprintf(stderr, "Invalid val=%d\n",path);
1630 return -2;
1631 }
1632 ret = mixer_ctl_set_value(ctl, 0, path);
1633
1634 if (ret){
1635 fprintf(stderr, "Error: set value,ret=%d\n",ret);
1636 return -2;
1637 }
1638 return 0;
1639}
1640
1641
1642
1643
1644int mix_get_vp_path(struct mixer *mixer, int *path)
1645{
1646 struct mixer_ctl *ctl;
1647 int val;
1648 unsigned int num_enums;
1649
1650 printf("%s: start !\n",__func__);
1651 char name[] = "voice processing path select";
1652 ctl = mixer_get_ctl_by_name(mixer, name);
1653 if (!ctl) {
1654 fprintf(stderr, "Invalid mixer control\n");
1655 return -1;
1656 }
1657
1658 num_enums = mixer_ctl_get_num_enums(ctl);
1659
1660
1661 val = mixer_ctl_get_value(ctl, 0);
1662 if((val < 0)||(val >= num_enums)){
1663 fprintf(stderr, "Invalid val=%d\n",val);
1664 return -2;
1665 }
1666 printf("%s: val=%d !\n",__func__,val);
1667 *path = val;
1668 return 0;
1669}
1670
1671
1672
1673int mix_set_vp_path_st(struct mixer *mixer, char *path)
1674{
1675 struct mixer_ctl *ctl;
1676 char name[] = "voice processing path select";
1677 ctl = mixer_get_ctl_by_name(mixer, name);
1678 if (!ctl) {
1679 fprintf(stderr, "Invalid mixer control\n");
1680 return -1;
1681 }
1682
1683 //mixer_ctl_set_value(ctl, 0, path);
1684 if (mixer_ctl_set_enum_by_string(ctl, path))
1685 fprintf(stderr, "Error: invalid enum value\n");
1686 return 0;
1687}
1688
1689
1690
1691
1692int mix_get_vp_path_st(struct mixer *mixer, int *path)
1693{
1694 struct mixer_ctl *ctl;
1695 int val;
1696 unsigned int num_enums;
1697 unsigned int i;
1698 const char *string;
1699
1700 printf("%s: start !\n",__func__);
1701 char name[] = "voice processing path select";
1702 ctl = mixer_get_ctl_by_name(mixer, name);
1703 if (!ctl) {
1704 fprintf(stderr, "Invalid mixer control\n");
1705 return -1;
1706 }
1707
1708 num_enums = mixer_ctl_get_num_enums(ctl);
1709
1710
1711 val = mixer_ctl_get_value(ctl, 0);
1712 if((val < 0)||(val >= num_enums)){
1713 fprintf(stderr, "Invalid val=%d\n",val);
1714 return -2;
1715 }
1716 printf("%s: val=%d !\n",__func__,val);
1717
1718 string = mixer_ctl_get_enum_string(ctl, val);
1719
1720 if(string == NULL){
xf.li742dd022023-06-08 01:43:32 -07001721 fprintf(stderr, "err, string is NULL \n");
xf.libdd93d52023-05-12 07:10:14 -07001722 return -2;
1723 }
1724 printf("%s: string=%s !\n",__func__,string);
1725 path = string;
1726 return 0;
1727}
1728
1729
1730
lh9ed821d2023-04-07 01:36:19 -07001731int mix_set_voice_path(struct mixer *mixer, int path)
1732{
1733 int i;
1734/*
1735 for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) {
1736 tinymix_set_value_test(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values);
1737 }
1738
1739 for(i = 0;i<ARRAY_SIZE(common_out_para_audio);i++)
1740 {
1741 tinymix_set_value_test(mixer,common_out_para_audio[i].control,common_out_para_audio[i].values);
1742 }
1743*/
1744 switch (path) {
1745 case T_OUTPUT_RECEIVER:
1746 for (i = 0; i < ARRAY_SIZE(handset_inoutpath_para_voice); i++) {
1747 mix_set_value_wrap(mixer, handset_inoutpath_para_voice[i].control, handset_inoutpath_para_voice[i].values);
1748 }
1749 break;
1750 case T_OUTPUT_SPEAKER:
1751 for (i = 0; i < ARRAY_SIZE(spk_inoutpath_para_voice); i++) {
1752 mix_set_value_wrap(mixer, spk_inoutpath_para_voice[i].control, spk_inoutpath_para_voice[i].values);
1753 }
1754 break;
1755 case T_OUTPUT_HEADSET:
1756 for (i = 0; i < ARRAY_SIZE(headset_inoutpath_para_voice); i++) {
1757 mix_set_value_wrap(mixer, headset_inoutpath_para_voice[i].control, headset_inoutpath_para_voice[i].values);
1758 }
1759 default:
1760 break;
1761 }
1762
1763 return 0;
1764}
1765
1766
1767int mix_set_in_call_tone(struct mixer *mixer, int tontype)
1768{
1769 struct mixer_ctl *ctl;
1770 char name[] = "voice tone sel";
1771 ctl = mixer_get_ctl_by_name(mixer, name);
1772 if (!ctl) {
1773 fprintf(stderr, "Invalid mixer control\n");
1774 return -1;
1775 }
1776
1777 mixer_ctl_set_value(ctl, 0, tontype);
1778
1779 return 0;
1780}
1781
1782int mix_set_default_param(struct mixer *mixer)
1783{
1784 int i;
1785 for (i = 0; i < ARRAY_SIZE(init_default_para); i++) {
1786 mix_set_value_wrap(mixer, init_default_para[i].control, init_default_para[i].values);
1787 }
1788
1789 return 0;
1790}
xf.libdd93d52023-05-12 07:10:14 -07001791
1792int mix_get_voice_path(struct mixer *mixer, int *path)
1793{
1794
1795 mix_get_value_wrap(mixer, "audio path select", path);
1796
1797 return 0;
1798
1799}
1800#define VOCIE_SND_CARD_NUM 0
1801
1802
1803
1804//ÉèÖÃvoiceÒôƵÉ豸ģʽ dev_mode£ºhandset,speaker,headset 0 ±íʾ³É¹¦£¬ ÆäËü±íʾÓдíÎó
1805int set_voice_device_mode(int dev_mode)
1806{
1807
1808 struct mixer *voice_mixer = NULL;
1809 printf("%s: start dev_mode=%d!\n",__func__, dev_mode);
1810
1811 if ((dev_mode < T_OUTPUT_HANDSET ) ||(dev_mode > T_OUTPUT_HEADSET)){
1812 printf("%s: dev_mode not support, dev_mode=%d!\n",__func__, dev_mode);
1813 return -1;
1814 }
1815
1816 //open mixer dev for control
1817 voice_mixer = mixer_open(VOCIE_SND_CARD_NUM);
1818 if (!voice_mixer) {
1819 printf("voice_mixer open failed!\n");
1820 return -1;
1821 }
1822
1823 //config mixer dev
1824 mix_set_voice_path(voice_mixer, dev_mode);
1825
1826 //close mixer
1827 mixer_close(voice_mixer);
1828 voice_mixer = NULL;
1829
1830
1831 return 0;
1832
1833
1834}
1835
1836
1837
lh9ed821d2023-04-07 01:36:19 -07001838#endif