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