LibDriver WM8978
Loading...
Searching...
No Matches
driver_wm8978_basic.c
Go to the documentation of this file.
1
36
37#include "driver_wm8978_basic.h"
38
39static wm8978_handle_t gs_handle;
40
50{
51 uint8_t res;
52 uint8_t reg;
53
54 /* link interface function */
61
62 /* wm8978 init */
63 res = wm8978_init(&gs_handle);
64 if (res != 0)
65 {
66 wm8978_interface_debug_print("wm8978: init failed.\n");
67
68 return 1;
69 }
70
71 /* set default dc buffer */
73 if (res != 0)
74 {
75 wm8978_interface_debug_print("wm8978: set dc buffer failed.\n");
76 (void)wm8978_deinit(&gs_handle);
77
78 return 1;
79 }
80
81 /* set default out4 mixer */
83 if (res != 0)
84 {
85 wm8978_interface_debug_print("wm8978: set out4 mixer failed.\n");
86 (void)wm8978_deinit(&gs_handle);
87
88 return 1;
89 }
90
91 /* set default out3 mixer */
93 if (res != 0)
94 {
95 wm8978_interface_debug_print("wm8978: set out3 mixer failed.\n");
96 (void)wm8978_deinit(&gs_handle);
97
98 return 1;
99 }
100
101 /* set default pll */
102 res = wm8978_set_pll(&gs_handle, WM8978_BASIC_DEFAULT_PLL);
103 if (res != 0)
104 {
105 wm8978_interface_debug_print("wm8978: set pll failed.\n");
106 (void)wm8978_deinit(&gs_handle);
107
108 return 1;
109 }
110
111 /* set default microphone bias */
113 if (res != 0)
114 {
115 wm8978_interface_debug_print("wm8978: set microphone bias failed.\n");
116 (void)wm8978_deinit(&gs_handle);
117
118 return 1;
119 }
120
121 /* set default analogue amplifier bias */
123 if (res != 0)
124 {
125 wm8978_interface_debug_print("wm8978: set analogue amplifier bias failed.\n");
126 (void)wm8978_deinit(&gs_handle);
127
128 return 1;
129 }
130
131 /* set default unused input output tie off buffer */
133 if (res != 0)
134 {
135 wm8978_interface_debug_print("wm8978: set unused input output tie off buffer failed.\n");
136 (void)wm8978_deinit(&gs_handle);
137
138 return 1;
139 }
140
141 /* set default reference impedance */
143 if (res != 0)
144 {
145 wm8978_interface_debug_print("wm8978: set reference impedance failed.\n");
146 (void)wm8978_deinit(&gs_handle);
147
148 return 1;
149 }
150
151 /* disable sleep */
152 res = wm8978_set_sleep(&gs_handle, WM8978_BOOL_FALSE);
153 if (res != 0)
154 {
155 wm8978_interface_debug_print("wm8978: set sleep failed.\n");
156 (void)wm8978_deinit(&gs_handle);
157
158 return 1;
159 }
160
161 /* set default out4 */
163 if (res != 0)
164 {
165 wm8978_interface_debug_print("wm8978: set out4 failed.\n");
166 (void)wm8978_deinit(&gs_handle);
167
168 return 1;
169 }
170
171 /* set default out3 */
173 if (res != 0)
174 {
175 wm8978_interface_debug_print("wm8978: set out3 failed.\n");
176 (void)wm8978_deinit(&gs_handle);
177
178 return 1;
179 }
180
181 /* set default bclk polarity */
183 if (res != 0)
184 {
185 wm8978_interface_debug_print("wm8978: set bclk polarity failed.\n");
186 (void)wm8978_deinit(&gs_handle);
187
188 return 1;
189 }
190
191 /* set default lrclk polarity */
193 if (res != 0)
194 {
195 wm8978_interface_debug_print("wm8978: set lrclk polarity failed.\n");
196 (void)wm8978_deinit(&gs_handle);
197
198 return 1;
199 }
200
201 /* set default dac appear */
203 if (res != 0)
204 {
205 wm8978_interface_debug_print("wm8978: set dac appear failed.\n");
206 (void)wm8978_deinit(&gs_handle);
207
208 return 1;
209 }
210
211 /* set default adc appear */
213 if (res != 0)
214 {
215 wm8978_interface_debug_print("wm8978: set adc appear failed.\n");
216 (void)wm8978_deinit(&gs_handle);
217
218 return 1;
219 }
220
221 /* set default companding 8bit mode */
223 if (res != 0)
224 {
225 wm8978_interface_debug_print("wm8978: set companding 8bit mode failed.\n");
226 (void)wm8978_deinit(&gs_handle);
227
228 return 1;
229 }
230
231 /* set default data format */
233 if (res != 0)
234 {
235 wm8978_interface_debug_print("wm8978: set data format failed.\n");
236 (void)wm8978_deinit(&gs_handle);
237
238 return 1;
239 }
240
241 /* set default loopback */
243 if (res != 0)
244 {
245 wm8978_interface_debug_print("wm8978: set loopback failed.\n");
246 (void)wm8978_deinit(&gs_handle);
247
248 return 1;
249 }
250
251 /* set default clksel */
253 if (res != 0)
254 {
255 wm8978_interface_debug_print("wm8978: set clksel failed.\n");
256 (void)wm8978_deinit(&gs_handle);
257
258 return 1;
259 }
260
261 /* set default mclk div */
263 if (res != 0)
264 {
265 wm8978_interface_debug_print("wm8978: set mclk div failed.\n");
266 (void)wm8978_deinit(&gs_handle);
267
268 return 1;
269 }
270
271 /* set default bclk div */
273 if (res != 0)
274 {
275 wm8978_interface_debug_print("wm8978: set bclk div failed.\n");
276 (void)wm8978_deinit(&gs_handle);
277
278 return 1;
279 }
280
281 /* set default clock mode */
283 if (res != 0)
284 {
285 wm8978_interface_debug_print("wm8978: set clock mode failed.\n");
286 (void)wm8978_deinit(&gs_handle);
287
288 return 1;
289 }
290
291 /* set default approximate sample rate */
293 if (res != 0)
294 {
295 wm8978_interface_debug_print("wm8978: set approximate sample rate failed.\n");
296 (void)wm8978_deinit(&gs_handle);
297
298 return 1;
299 }
300
301 /* set default slow clock */
303 if (res != 0)
304 {
305 wm8978_interface_debug_print("wm8978: set slow clock failed.\n");
306 (void)wm8978_deinit(&gs_handle);
307
308 return 1;
309 }
310
311 /* set default pll div */
313 if (res != 0)
314 {
315 wm8978_interface_debug_print("wm8978: set pll div failed.\n");
316 (void)wm8978_deinit(&gs_handle);
317
318 return 1;
319 }
320
321 /* set default gpio1 polarity */
323 if (res != 0)
324 {
325 wm8978_interface_debug_print("wm8978: set gpio1 polarity failed.\n");
326 (void)wm8978_deinit(&gs_handle);
327
328 return 1;
329 }
330
331 /* set default gpio1 select */
333 if (res != 0)
334 {
335 wm8978_interface_debug_print("wm8978: set gpio1 select failed.\n");
336 (void)wm8978_deinit(&gs_handle);
337
338 return 1;
339 }
340
341 /* set default vmid 1 */
343 if (res != 0)
344 {
345 wm8978_interface_debug_print("wm8978: set vmid 1 failed.\n");
346 (void)wm8978_deinit(&gs_handle);
347
348 return 1;
349 }
350
351 /* set default vmid 0 */
353 if (res != 0)
354 {
355 wm8978_interface_debug_print("wm8978: set vmid 0 failed.\n");
356 (void)wm8978_deinit(&gs_handle);
357
358 return 1;
359 }
360
361 /* set default jack detection */
363 if (res != 0)
364 {
365 wm8978_interface_debug_print("wm8978: set jack detection failed.\n");
366 (void)wm8978_deinit(&gs_handle);
367
368 return 1;
369 }
370
371 /* set default jack gpio */
373 if (res != 0)
374 {
375 wm8978_interface_debug_print("wm8978: set jack gpio failed.\n");
376 (void)wm8978_deinit(&gs_handle);
377
378 return 1;
379 }
380
381 /* set default soft mute */
383 if (res != 0)
384 {
385 wm8978_interface_debug_print("wm8978: set soft mute failed.\n");
386 (void)wm8978_deinit(&gs_handle);
387
388 return 1;
389 }
390
391 /* set default dac oversample rate */
393 if (res != 0)
394 {
395 wm8978_interface_debug_print("wm8978: set dac oversample rate failed.\n");
396 (void)wm8978_deinit(&gs_handle);
397
398 return 1;
399 }
400
401 /* set default amute */
403 if (res != 0)
404 {
405 wm8978_interface_debug_print("wm8978: set amute failed.\n");
406 (void)wm8978_deinit(&gs_handle);
407
408 return 1;
409 }
410
411 /* set default right dac output polarity */
413 if (res != 0)
414 {
415 wm8978_interface_debug_print("wm8978: set right dac output polarity failed.\n");
416 (void)wm8978_deinit(&gs_handle);
417
418 return 1;
419 }
420
421 /* set default left dac output polarity */
423 if (res != 0)
424 {
425 wm8978_interface_debug_print("wm8978: set left dac output polarity failed.\n");
426 (void)wm8978_deinit(&gs_handle);
427
428 return 1;
429 }
430
431 /* set default volume */
433 if (res != 0)
434 {
435 wm8978_interface_debug_print("wm8978: volume convert to register failed.\n");
436 (void)wm8978_deinit(&gs_handle);
437
438 return 1;
439 }
440
441 /* set dac left volume */
442 res = wm8978_set_dac_left_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
443 if (res != 0)
444 {
445 wm8978_interface_debug_print("wm8978: set dac left volume failed.\n");
446 (void)wm8978_deinit(&gs_handle);
447
448 return 1;
449 }
450
451 /* set dac right volume */
452 res = wm8978_set_dac_right_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
453 if (res != 0)
454 {
455 wm8978_interface_debug_print("wm8978: set dac right volume failed.\n");
456 (void)wm8978_deinit(&gs_handle);
457
458 return 1;
459 }
460
461 /* set default jack logic 0 */
463 if (res != 0)
464 {
465 wm8978_interface_debug_print("wm8978: set jack logic 0 failed.\n");
466 (void)wm8978_deinit(&gs_handle);
467
468 return 1;
469 }
470
471 /* set default jack logic 1 */
473 if (res != 0)
474 {
475 wm8978_interface_debug_print("wm8978: set jack logic 1 failed.\n");
476 (void)wm8978_deinit(&gs_handle);
477
478 return 1;
479 }
480
481 /* set default jack logic 0 */
483 if (res != 0)
484 {
485 wm8978_interface_debug_print("wm8978: set jack logic 0 failed.\n");
486 (void)wm8978_deinit(&gs_handle);
487
488 return 1;
489 }
490
491 /* set default jack logic 1 */
493 if (res != 0)
494 {
495 wm8978_interface_debug_print("wm8978: set jack logic 1 failed.\n");
496 (void)wm8978_deinit(&gs_handle);
497
498 return 1;
499 }
500
501 /* set default jack logic 0 */
503 if (res != 0)
504 {
505 wm8978_interface_debug_print("wm8978: set jack logic 0 failed.\n");
506 (void)wm8978_deinit(&gs_handle);
507
508 return 1;
509 }
510
511 /* set default jack logic 0 */
513 if (res != 0)
514 {
515 wm8978_interface_debug_print("wm8978: set jack logic 0 failed.\n");
516 (void)wm8978_deinit(&gs_handle);
517
518 return 1;
519 }
520
521 /* set default jack logic 1 */
523 if (res != 0)
524 {
525 wm8978_interface_debug_print("wm8978: set jack logic 1 failed.\n");
526 (void)wm8978_deinit(&gs_handle);
527
528 return 1;
529 }
530
531 /* set default jack logic 1 */
533 if (res != 0)
534 {
535 wm8978_interface_debug_print("wm8978: set jack logic 1 failed.\n");
536 (void)wm8978_deinit(&gs_handle);
537
538 return 1;
539 }
540
541 /* set default high pass filter */
543 if (res != 0)
544 {
545 wm8978_interface_debug_print("wm8978: set high pass filter failed.\n");
546 (void)wm8978_deinit(&gs_handle);
547
548 return 1;
549 }
550
551 /* set default mode */
553 if (res != 0)
554 {
555 wm8978_interface_debug_print("wm8978: set mode failed.\n");
556 (void)wm8978_deinit(&gs_handle);
557
558 return 1;
559 }
560
561 /* set default high pass filter cut off */
563 if (res != 0)
564 {
565 wm8978_interface_debug_print("wm8978: set high pass filter cut off failed.\n");
566 (void)wm8978_deinit(&gs_handle);
567
568 return 1;
569 }
570
571 /* set default adc oversample rate */
573 if (res != 0)
574 {
575 wm8978_interface_debug_print("wm8978: set adc oversample rate failed.\n");
576 (void)wm8978_deinit(&gs_handle);
577
578 return 1;
579 }
580
581 /* set default adc right channel polarity */
583 if (res != 0)
584 {
585 wm8978_interface_debug_print("wm8978: set adc right channel polarity failed.\n");
586 (void)wm8978_deinit(&gs_handle);
587
588 return 1;
589 }
590
591 /* set default adc left channel polarity */
593 if (res != 0)
594 {
595 wm8978_interface_debug_print("wm8978: set adc left channel polarity failed.\n");
596 (void)wm8978_deinit(&gs_handle);
597
598 return 1;
599 }
600
601 /* set default adc volume */
603 if (res != 0)
604 {
605 wm8978_interface_debug_print("wm8978: volume convert to register failed.\n");
606 (void)wm8978_deinit(&gs_handle);
607
608 return 1;
609 }
610
611 /* set adc left volume */
612 res = wm8978_set_adc_left_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
613 if (res != 0)
614 {
615 wm8978_interface_debug_print("wm8978: set adc left volume failed.\n");
616 (void)wm8978_deinit(&gs_handle);
617
618 return 1;
619 }
620
621 /* set adc right volume */
622 res = wm8978_set_adc_right_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
623 if (res != 0)
624 {
625 wm8978_interface_debug_print("wm8978: set adc right volume failed.\n");
626 (void)wm8978_deinit(&gs_handle);
627
628 return 1;
629 }
630
631 /* set default equaliser apply */
633 if (res != 0)
634 {
635 wm8978_interface_debug_print("wm8978: set equaliser apply failed.\n");
636 (void)wm8978_deinit(&gs_handle);
637
638 return 1;
639 }
640
641 /* set default eq1 cut off */
643 if (res != 0)
644 {
645 wm8978_interface_debug_print("wm8978: set eq1 cut off failed.\n");
646 (void)wm8978_deinit(&gs_handle);
647
648 return 1;
649 }
650
651 /* set default eq1 gain */
653 if (res != 0)
654 {
655 wm8978_interface_debug_print("wm8978: eq gain convert to register failed.\n");
656 (void)wm8978_deinit(&gs_handle);
657
658 return 1;
659 }
660
661 /* set eq1 gain */
662 res = wm8978_set_eq1_gain(&gs_handle, reg);
663 if (res != 0)
664 {
665 wm8978_interface_debug_print("wm8978: set eq1 gain failed.\n");
666 (void)wm8978_deinit(&gs_handle);
667
668 return 1;
669 }
670
671 /* set default eq2 bandwidth */
673 if (res != 0)
674 {
675 wm8978_interface_debug_print("wm8978: set eq2 bandwidth failed.\n");
676 (void)wm8978_deinit(&gs_handle);
677
678 return 1;
679 }
680
681 /* set default eq2 centre freq */
683 if (res != 0)
684 {
685 wm8978_interface_debug_print("wm8978: set eq2 centre freq failed.\n");
686 (void)wm8978_deinit(&gs_handle);
687
688 return 1;
689 }
690
691 /* set default eq2 gain */
693 if (res != 0)
694 {
695 wm8978_interface_debug_print("wm8978: eq gain convert to register failed.\n");
696 (void)wm8978_deinit(&gs_handle);
697
698 return 1;
699 }
700
701 /* set eq2 gain */
702 res = wm8978_set_eq2_gain(&gs_handle, reg);
703 if (res != 0)
704 {
705 wm8978_interface_debug_print("wm8978: set eq2 gain failed.\n");
706 (void)wm8978_deinit(&gs_handle);
707
708 return 1;
709 }
710
711 /* set default eq3 bandwidth */
713 if (res != 0)
714 {
715 wm8978_interface_debug_print("wm8978: set eq3 bandwidth failed.\n");
716 (void)wm8978_deinit(&gs_handle);
717
718 return 1;
719 }
720
721 /* set default eq3 centre freq */
723 if (res != 0)
724 {
725 wm8978_interface_debug_print("wm8978: set eq3 centre freq failed.\n");
726 (void)wm8978_deinit(&gs_handle);
727
728 return 1;
729 }
730
731 /* set default eq3 gain */
733 if (res != 0)
734 {
735 wm8978_interface_debug_print("wm8978: eq gain convert to register failed.\n");
736 (void)wm8978_deinit(&gs_handle);
737
738 return 1;
739 }
740
741 /* set eq3 gain */
742 res = wm8978_set_eq3_gain(&gs_handle, reg);
743 if (res != 0)
744 {
745 wm8978_interface_debug_print("wm8978: set eq3 gain failed.\n");
746 (void)wm8978_deinit(&gs_handle);
747
748 return 1;
749 }
750
751 /* set default eq4 bandwidth */
753 if (res != 0)
754 {
755 wm8978_interface_debug_print("wm8978: set eq4 bandwidth failed.\n");
756 (void)wm8978_deinit(&gs_handle);
757
758 return 1;
759 }
760
761 /* set default eq4 centre freq */
763 if (res != 0)
764 {
765 wm8978_interface_debug_print("wm8978: set eq4 centre freq failed.\n");
766 (void)wm8978_deinit(&gs_handle);
767
768 return 1;
769 }
770
771 /* set default eq4 gain */
773 if (res != 0)
774 {
775 wm8978_interface_debug_print("wm8978: eq gain convert to register failed.\n");
776 (void)wm8978_deinit(&gs_handle);
777
778 return 1;
779 }
780
781 /* set eq4 gain */
782 res = wm8978_set_eq4_gain(&gs_handle, reg);
783 if (res != 0)
784 {
785 wm8978_interface_debug_print("wm8978: set eq4 gain failed.\n");
786 (void)wm8978_deinit(&gs_handle);
787
788 return 1;
789 }
790
791 /* set default eq5 cut off */
793 if (res != 0)
794 {
795 wm8978_interface_debug_print("wm8978: set eq5 cut off failed.\n");
796 (void)wm8978_deinit(&gs_handle);
797
798 return 1;
799 }
800
801 /* set default eq5 gain */
803 if (res != 0)
804 {
805 wm8978_interface_debug_print("wm8978: eq gain convert to register failed.\n");
806 (void)wm8978_deinit(&gs_handle);
807
808 return 1;
809 }
810
811 /* set eq5 gain */
812 res = wm8978_set_eq5_gain(&gs_handle, reg);
813 if (res != 0)
814 {
815 wm8978_interface_debug_print("wm8978: set eq5 gain failed.\n");
816 (void)wm8978_deinit(&gs_handle);
817
818 return 1;
819 }
820
821 /* set default dac digital limiter */
823 if (res != 0)
824 {
825 wm8978_interface_debug_print("wm8978: set dac digital limiter failed.\n");
826 (void)wm8978_deinit(&gs_handle);
827
828 return 1;
829 }
830
831 /* set default dac limiter decay */
833 if (res != 0)
834 {
835 wm8978_interface_debug_print("wm8978: set dac limiter decay failed.\n");
836 (void)wm8978_deinit(&gs_handle);
837
838 return 1;
839 }
840
841 /* set default dac limiter attack */
843 if (res != 0)
844 {
845 wm8978_interface_debug_print("wm8978: set dac limiter attack failed.\n");
846 (void)wm8978_deinit(&gs_handle);
847
848 return 1;
849 }
850
851 /* set default dac limiter level */
853 if (res != 0)
854 {
855 wm8978_interface_debug_print("wm8978: set dac limiter level failed.\n");
856 (void)wm8978_deinit(&gs_handle);
857
858 return 1;
859 }
860
861 /* set default dac limiter volume boost */
863 if (res != 0)
864 {
865 wm8978_interface_debug_print("wm8978: set dac limiter volume boost failed.\n");
866 (void)wm8978_deinit(&gs_handle);
867
868 return 1;
869 }
870
871 /* set default notch filter */
873 if (res != 0)
874 {
875 wm8978_interface_debug_print("wm8978: set notch filter failed.\n");
876 (void)wm8978_deinit(&gs_handle);
877
878 return 1;
879 }
880
881 /* set default notch filter a0 */
883 if (res != 0)
884 {
885 wm8978_interface_debug_print("wm8978: set notch filter a0 coefficient bit 13 7 failed.\n");
886 (void)wm8978_deinit(&gs_handle);
887
888 return 1;
889 }
890
891 /* set default notch filter a0 */
893 if (res != 0)
894 {
895 wm8978_interface_debug_print("wm8978: set notch filter a0 coefficient bit 6 0 failed.\n");
896 (void)wm8978_deinit(&gs_handle);
897
898 return 1;
899 }
900
901 /* set default notch filter a1 */
903 if (res != 0)
904 {
905 wm8978_interface_debug_print("wm8978: set notch filter a1 coefficient bit 13 7 failed.\n");
906 (void)wm8978_deinit(&gs_handle);
907
908 return 1;
909 }
910
911 /* set default notch filter a1 */
913 if (res != 0)
914 {
915 wm8978_interface_debug_print("wm8978: set notch filter a1 coefficient bit 6 0 failed.\n");
916 (void)wm8978_deinit(&gs_handle);
917
918 return 1;
919 }
920
921 /* set default alc */
922 res = wm8978_set_alc(&gs_handle, WM8978_BASIC_DEFAULT_ALC);
923 if (res != 0)
924 {
925 wm8978_interface_debug_print("wm8978: set alc failed.\n");
926 (void)wm8978_deinit(&gs_handle);
927
928 return 1;
929 }
930
931 /* set default alc max gain */
933 if (res != 0)
934 {
935 wm8978_interface_debug_print("wm8978: set alc max gain failed.\n");
936 (void)wm8978_deinit(&gs_handle);
937
938 return 1;
939 }
940
941 /* set default alc min gain */
943 if (res != 0)
944 {
945 wm8978_interface_debug_print("wm8978: set alc min gain failed.\n");
946 (void)wm8978_deinit(&gs_handle);
947
948 return 1;
949 }
950
951 /* set default alc hold time */
953 if (res != 0)
954 {
955 wm8978_interface_debug_print("wm8978: alc hold time convert to register failed.\n");
956 (void)wm8978_deinit(&gs_handle);
957
958 return 1;
959 }
960
961 /* set alc hold time */
962 res = wm8978_set_alc_hold_time(&gs_handle, reg);
963 if (res != 0)
964 {
965 wm8978_interface_debug_print("wm8978: set alc hold time failed.\n");
966 (void)wm8978_deinit(&gs_handle);
967
968 return 1;
969 }
970
971 /* set default alc level */
973 if (res != 0)
974 {
975 wm8978_interface_debug_print("wm8978: set alc level failed.\n");
976 (void)wm8978_deinit(&gs_handle);
977
978 return 1;
979 }
980
981 /* set default alc mode */
983 if (res != 0)
984 {
985 wm8978_interface_debug_print("wm8978: set alc mode failed.\n");
986 (void)wm8978_deinit(&gs_handle);
987
988 return 1;
989 }
990
991 /* set default alc decay */
993 if (res != 0)
994 {
995 wm8978_interface_debug_print("wm8978: set alc decay failed.\n");
996 (void)wm8978_deinit(&gs_handle);
997
998 return 1;
999 }
1000
1001 /* set default alc attack */
1003 if (res != 0)
1004 {
1005 wm8978_interface_debug_print("wm8978: set alc attack failed.\n");
1006 (void)wm8978_deinit(&gs_handle);
1007
1008 return 1;
1009 }
1010
1011 /* set default alc noise gate */
1013 if (res != 0)
1014 {
1015 wm8978_interface_debug_print("wm8978: set alc noise gate failed.\n");
1016 (void)wm8978_deinit(&gs_handle);
1017
1018 return 1;
1019 }
1020
1021 /* set default alc noise gate threshold */
1023 if (res != 0)
1024 {
1025 wm8978_interface_debug_print("wm8978: alc noise gate threshold convert to register failed.\n");
1026 (void)wm8978_deinit(&gs_handle);
1027
1028 return 1;
1029 }
1030
1031 /* set alc noise gate threshold */
1032 res = wm8978_set_alc_noise_gate_threshold(&gs_handle, reg);
1033 if (res != 0)
1034 {
1035 wm8978_interface_debug_print("wm8978: set alc noise gate threshold failed.\n");
1036 (void)wm8978_deinit(&gs_handle);
1037
1038 return 1;
1039 }
1040
1041 /* set default mclk divide by 2 */
1043 if (res != 0)
1044 {
1045 wm8978_interface_debug_print("wm8978: set mclk divide by 2 failed.\n");
1046 (void)wm8978_deinit(&gs_handle);
1047
1048 return 1;
1049 }
1050
1051 /* set default plln */
1052 res = wm8978_set_plln(&gs_handle, WM8978_BASIC_DEFAULT_PLLN);
1053 if (res != 0)
1054 {
1055 wm8978_interface_debug_print("wm8978: set plln failed.\n");
1056 (void)wm8978_deinit(&gs_handle);
1057
1058 return 1;
1059 }
1060
1061 /* set default pll freq */
1063 if (res != 0)
1064 {
1065 wm8978_interface_debug_print("wm8978: set pll freq failed.\n");
1066 (void)wm8978_deinit(&gs_handle);
1067
1068 return 1;
1069 }
1070
1071 /* set default depth 3d */
1073 if (res != 0)
1074 {
1075 wm8978_interface_debug_print("wm8978: depth 3d convert to register failed.\n");
1076 (void)wm8978_deinit(&gs_handle);
1077
1078 return 1;
1079 }
1080
1081 /* set depth 3d */
1082 res = wm8978_set_depth_3d(&gs_handle, reg);
1083 if (res != 0)
1084 {
1085 wm8978_interface_debug_print("wm8978: set depth 3d failed.\n");
1086 (void)wm8978_deinit(&gs_handle);
1087
1088 return 1;
1089 }
1090
1091 /* set default right out1 */
1093 if (res != 0)
1094 {
1095 wm8978_interface_debug_print("wm8978: set right out1 failed.\n");
1096 (void)wm8978_deinit(&gs_handle);
1097
1098 return 1;
1099 }
1100
1101 /* set default left out1 */
1103 if (res != 0)
1104 {
1105 wm8978_interface_debug_print("wm8978: set left out1 failed.\n");
1106 (void)wm8978_deinit(&gs_handle);
1107
1108 return 1;
1109 }
1110
1111 /* set default right channel input boost */
1113 if (res != 0)
1114 {
1115 wm8978_interface_debug_print("wm8978: set right channel input boost failed.\n");
1116 (void)wm8978_deinit(&gs_handle);
1117
1118 return 1;
1119 }
1120
1121 /* set default left channel input boost */
1123 if (res != 0)
1124 {
1125 wm8978_interface_debug_print("wm8978: set left channel input boost failed.\n");
1126 (void)wm8978_deinit(&gs_handle);
1127
1128 return 1;
1129 }
1130
1131 /* set default left out2 */
1133 if (res != 0)
1134 {
1135 wm8978_interface_debug_print("wm8978: set left out2 failed.\n");
1136 (void)wm8978_deinit(&gs_handle);
1137
1138 return 1;
1139 }
1140
1141 /* set default right out2 */
1143 if (res != 0)
1144 {
1145 wm8978_interface_debug_print("wm8978: set right out2 failed.\n");
1146 (void)wm8978_deinit(&gs_handle);
1147
1148 return 1;
1149 }
1150
1151 /* set default right output channel mixer */
1153 if (res != 0)
1154 {
1155 wm8978_interface_debug_print("wm8978: set right output channel mixer failed.\n");
1156 (void)wm8978_deinit(&gs_handle);
1157
1158 return 1;
1159 }
1160
1161 /* set default left output channel mixer */
1163 if (res != 0)
1164 {
1165 wm8978_interface_debug_print("wm8978: set left output channel mixer failed.\n");
1166 (void)wm8978_deinit(&gs_handle);
1167
1168 return 1;
1169 }
1170
1171 /* set default mute input to inv rout2 mixer */
1173 if (res != 0)
1174 {
1175 wm8978_interface_debug_print("wm8978: set mute input to inv rout2 mixer failed.\n");
1176 (void)wm8978_deinit(&gs_handle);
1177
1178 return 1;
1179 }
1180
1181 /* set default inv rout2 mixer */
1183 if (res != 0)
1184 {
1185 wm8978_interface_debug_print("wm8978: set inv rout2 mixer failed.\n");
1186 (void)wm8978_deinit(&gs_handle);
1187
1188 return 1;
1189 }
1190
1191 /* set beep volume */
1193 if (res != 0)
1194 {
1195 wm8978_interface_debug_print("wm8978: beep volume convert to register failed.\n");
1196 (void)wm8978_deinit(&gs_handle);
1197
1198 return 1;
1199 }
1200
1201 /* set beep volume */
1202 res = wm8978_set_beep_volume(&gs_handle, reg);
1203 if (res != 0)
1204 {
1205 wm8978_interface_debug_print("wm8978: set beep volume failed.\n");
1206 (void)wm8978_deinit(&gs_handle);
1207
1208 return 1;
1209 }
1210
1211 /* set default sleep */
1212 res = wm8978_set_beep(&gs_handle, WM8978_BASIC_DEFAULT_BEEP);
1213 if (res != 0)
1214 {
1215 wm8978_interface_debug_print("wm8978: set beep failed.\n");
1216 (void)wm8978_deinit(&gs_handle);
1217
1218 return 1;
1219 }
1220
1221 /* set default microphone bias voltage */
1223 if (res != 0)
1224 {
1225 wm8978_interface_debug_print("wm8978: set microphone bias voltage failed.\n");
1226 (void)wm8978_deinit(&gs_handle);
1227
1228 return 1;
1229 }
1230
1231 /* set default right channel input pga positive */
1233 if (res != 0)
1234 {
1235 wm8978_interface_debug_print("wm8978: set right channel input pga positive failed.\n");
1236 (void)wm8978_deinit(&gs_handle);
1237
1238 return 1;
1239 }
1240
1241 /* set default left channel input pga positive */
1243 if (res != 0)
1244 {
1245 wm8978_interface_debug_print("wm8978: set left channel input pga positive failed.\n");
1246 (void)wm8978_deinit(&gs_handle);
1247
1248 return 1;
1249 }
1250
1251 /* set default left dac output to right output mixer */
1253 if (res != 0)
1254 {
1255 wm8978_interface_debug_print("wm8978: set left dac output to right output mixer failed.\n");
1256 (void)wm8978_deinit(&gs_handle);
1257
1258 return 1;
1259 }
1260
1261 /* set default right dac output to left output mixer */
1263 if (res != 0)
1264 {
1265 wm8978_interface_debug_print("wm8978: set right dac output to left output mixer failed.\n");
1266 (void)wm8978_deinit(&gs_handle);
1267
1268 return 1;
1269 }
1270
1271 /* set default out4 boost */
1273 if (res != 0)
1274 {
1275 wm8978_interface_debug_print("wm8978: set out4 boost failed.\n");
1276 (void)wm8978_deinit(&gs_handle);
1277
1278 return 1;
1279 }
1280
1281 /* set default out3 boost */
1283 if (res != 0)
1284 {
1285 wm8978_interface_debug_print("wm8978: set out3 boost failed.\n");
1286 (void)wm8978_deinit(&gs_handle);
1287
1288 return 1;
1289 }
1290
1291 /* set default speaker boost */
1293 if (res != 0)
1294 {
1295 wm8978_interface_debug_print("wm8978: set speaker boost failed.\n");
1296 (void)wm8978_deinit(&gs_handle);
1297
1298 return 1;
1299 }
1300
1301 /* set default thermal shutdown */
1303 if (res != 0)
1304 {
1305 wm8978_interface_debug_print("wm8978: set thermal shutdown failed.\n");
1306 (void)wm8978_deinit(&gs_handle);
1307
1308 return 1;
1309 }
1310
1311 /* set default vref to analogue output resistance */
1313 if (res != 0)
1314 {
1315 wm8978_interface_debug_print("wm8978: set vref to analogue output resistance failed.\n");
1316 (void)wm8978_deinit(&gs_handle);
1317
1318 return 1;
1319 }
1320
1321 /* set default out3 mute */
1323 if (res != 0)
1324 {
1325 wm8978_interface_debug_print("wm8978: set out3 mute failed.\n");
1326 (void)wm8978_deinit(&gs_handle);
1327
1328 return 1;
1329 }
1330
1331 /* set default out4 mixer output to out3 */
1333 if (res != 0)
1334 {
1335 wm8978_interface_debug_print("wm8978: set out4 mixer output to out3 failed.\n");
1336 (void)wm8978_deinit(&gs_handle);
1337
1338 return 1;
1339 }
1340
1341 /* set default left adc input to out3 */
1343 if (res != 0)
1344 {
1345 wm8978_interface_debug_print("wm8978: set left adc input to out3 failed.\n");
1346 (void)wm8978_deinit(&gs_handle);
1347
1348 return 1;
1349 }
1350
1351 /* set default left dac mixer to out3 */
1353 if (res != 0)
1354 {
1355 wm8978_interface_debug_print("wm8978: set left dac mixer to out3 failed.\n");
1356 (void)wm8978_deinit(&gs_handle);
1357
1358 return 1;
1359 }
1360
1361 /* set default left dac output to out3 */
1363 if (res != 0)
1364 {
1365 wm8978_interface_debug_print("wm8978: set left dac output to out3 failed.\n");
1366 (void)wm8978_deinit(&gs_handle);
1367
1368 return 1;
1369 }
1370
1371 /* set default out4 mute */
1373 if (res != 0)
1374 {
1375 wm8978_interface_debug_print("wm8978: set out4 mute failed.\n");
1376 (void)wm8978_deinit(&gs_handle);
1377
1378 return 1;
1379 }
1380
1381 /* set default out4 attenuated by 6db */
1383 if (res != 0)
1384 {
1385 wm8978_interface_debug_print("wm8978: set out4 attenuated by 6db failed.\n");
1386 (void)wm8978_deinit(&gs_handle);
1387
1388 return 1;
1389 }
1390
1391 /* set default left dac mixer to out4 */
1393 if (res != 0)
1394 {
1395 wm8978_interface_debug_print("wm8978: set left dac mixer to out4 failed.\n");
1396 (void)wm8978_deinit(&gs_handle);
1397
1398 return 1;
1399 }
1400
1401 /* set default left dac to out4 */
1403 if (res != 0)
1404 {
1405 wm8978_interface_debug_print("wm8978: set left dac to out4 failed.\n");
1406 (void)wm8978_deinit(&gs_handle);
1407
1408 return 1;
1409 }
1410
1411 /* set default right adc input to out4 */
1413 if (res != 0)
1414 {
1415 wm8978_interface_debug_print("wm8978: set right adc input to out4 failed.\n");
1416 (void)wm8978_deinit(&gs_handle);
1417
1418 return 1;
1419 }
1420
1421 /* set default right dac mixer to out4 */
1423 if (res != 0)
1424 {
1425 wm8978_interface_debug_print("wm8978: set right dac mixer to out4 failed.\n");
1426 (void)wm8978_deinit(&gs_handle);
1427
1428 return 1;
1429 }
1430
1431 /* set default right dac output to out4 */
1433 if (res != 0)
1434 {
1435 wm8978_interface_debug_print("wm8978: set right dac output to out4 failed.\n");
1436 (void)wm8978_deinit(&gs_handle);
1437
1438 return 1;
1439 }
1440
1441 if (mode == WM8978_BASIC_MODE_PLAY)
1442 {
1443 /* enable right channel dac */
1445 if (res != 0)
1446 {
1447 wm8978_interface_debug_print("wm8978: set right channel dac failed.\n");
1448 (void)wm8978_deinit(&gs_handle);
1449
1450 return 1;
1451 }
1452
1453 /* enable left channel dac */
1455 if (res != 0)
1456 {
1457 wm8978_interface_debug_print("wm8978: set left channel dac failed.\n");
1458 (void)wm8978_deinit(&gs_handle);
1459
1460 return 1;
1461 }
1462
1463 /* disable right channel adc */
1465 if (res != 0)
1466 {
1467 wm8978_interface_debug_print("wm8978: set right channel adc failed.\n");
1468 (void)wm8978_deinit(&gs_handle);
1469
1470 return 1;
1471 }
1472
1473 /* disable left channel adc */
1475 if (res != 0)
1476 {
1477 wm8978_interface_debug_print("wm8978: set left channel adc failed.\n");
1478 (void)wm8978_deinit(&gs_handle);
1479
1480 return 1;
1481 }
1482
1483 /* disable right channel input pga */
1485 if (res != 0)
1486 {
1487 wm8978_interface_debug_print("wm8978: set right channel input pga failed.\n");
1488 (void)wm8978_deinit(&gs_handle);
1489
1490 return 1;
1491 }
1492
1493 /* disable left channel input pga */
1495 if (res != 0)
1496 {
1497 wm8978_interface_debug_print("wm8978: set left channel input pga failed.\n");
1498 (void)wm8978_deinit(&gs_handle);
1499
1500 return 1;
1501 }
1502
1503 /* disable right channel input pga negative */
1505 if (res != 0)
1506 {
1507 wm8978_interface_debug_print("wm8978: set right channel input pga negative failed.\n");
1508 (void)wm8978_deinit(&gs_handle);
1509
1510 return 1;
1511 }
1512
1513 /* disable right channel input pga amplifier positive */
1515 if (res != 0)
1516 {
1517 wm8978_interface_debug_print("wm8978: set right channel input pga amplifier positive failed.\n");
1518 (void)wm8978_deinit(&gs_handle);
1519
1520 return 1;
1521 }
1522
1523 /* disable left channel input pga negative */
1525 if (res != 0)
1526 {
1527 wm8978_interface_debug_print("wm8978: set left channel input pga negative failed.\n");
1528 (void)wm8978_deinit(&gs_handle);
1529
1530 return 1;
1531 }
1532
1533 /* disable left channel input pga amplifier positive */
1535 if (res != 0)
1536 {
1537 wm8978_interface_debug_print("wm8978: set left channel input pga amplifier positive failed.\n");
1538 (void)wm8978_deinit(&gs_handle);
1539
1540 return 1;
1541 }
1542
1543 /* enable left channel input pga boost */
1545 if (res != 0)
1546 {
1547 wm8978_interface_debug_print("wm8978: set left channel input pga boost failed.\n");
1548 (void)wm8978_deinit(&gs_handle);
1549
1550 return 1;
1551 }
1552
1553 /* -15db */
1555 if (res != 0)
1556 {
1557 wm8978_interface_debug_print("wm8978: left channel input boost stage convert to register failed.\n");
1558 (void)wm8978_deinit(&gs_handle);
1559
1560 return 1;
1561 }
1562
1563 /* set left channel input boost stage */
1564 res = wm8978_set_left_channel_input_boost_stage(&gs_handle, reg);
1565 if (res != 0)
1566 {
1567 wm8978_interface_debug_print("wm8978: set left channel input boost stage failed.\n");
1568 (void)wm8978_deinit(&gs_handle);
1569
1570 return 1;
1571 }
1572
1573 /* enable right channel input pga boost */
1575 if (res != 0)
1576 {
1577 wm8978_interface_debug_print("wm8978: set right channel input pga boost failed.\n");
1578 (void)wm8978_deinit(&gs_handle);
1579
1580 return 1;
1581 }
1582
1583 /* -15db */
1585 if (res != 0)
1586 {
1587 wm8978_interface_debug_print("wm8978: right channel input boost stage convert to register failed.\n");
1588 (void)wm8978_deinit(&gs_handle);
1589
1590 return 1;
1591 }
1592
1593 /* set right channel input boost stage */
1594 res = wm8978_set_right_channel_input_boost_stage(&gs_handle, reg);
1595 if (res != 0)
1596 {
1597 wm8978_interface_debug_print("wm8978: set right channel input boost stage failed.\n");
1598 (void)wm8978_deinit(&gs_handle);
1599
1600 return 1;
1601 }
1602
1603 /* -15db */
1605 if (res != 0)
1606 {
1607 wm8978_interface_debug_print("wm8978: auxiliary amplifier left channel input boost stage convert to register failed.\n");
1608 (void)wm8978_deinit(&gs_handle);
1609
1610 return 1;
1611 }
1612
1613 /* set auxiliary amplifier left channel input boost stage */
1615 if (res != 0)
1616 {
1617 wm8978_interface_debug_print("wm8978: set auxiliary amplifier left channel input boost stage failed.\n");
1618 (void)wm8978_deinit(&gs_handle);
1619
1620 return 1;
1621 }
1622
1623 /* -15db */
1625 if (res != 0)
1626 {
1627 wm8978_interface_debug_print("wm8978: auxiliary amplifier right channel input boost stage convert to register failed.\n");
1628 (void)wm8978_deinit(&gs_handle);
1629
1630 return 1;
1631 }
1632
1633 /* set auxiliary amplifier right channel input boost stage */
1635 if (res != 0)
1636 {
1637 wm8978_interface_debug_print("wm8978: set auxiliary amplifier right channel input boost stage failed.\n");
1638 (void)wm8978_deinit(&gs_handle);
1639
1640 return 1;
1641 }
1642
1643 /* -15db */
1645 if (res != 0)
1646 {
1647 wm8978_interface_debug_print("wm8978: left bypass volume control to output channel mixer convert to register failed.\n");
1648 (void)wm8978_deinit(&gs_handle);
1649
1650 return 1;
1651 }
1652
1653 /* set left bypass volume control to output channel mixer */
1655 if (res != 0)
1656 {
1657 wm8978_interface_debug_print("wm8978: set left bypass volume control to output channel mixer failed.\n");
1658 (void)wm8978_deinit(&gs_handle);
1659
1660 return 1;
1661 }
1662
1663 /* disable left bypass path to left output mixer */
1665 if (res != 0)
1666 {
1667 wm8978_interface_debug_print("wm8978: set left bypass path to left output mixer failed.\n");
1668 (void)wm8978_deinit(&gs_handle);
1669
1670 return 1;
1671 }
1672
1673 /* enable left dac output to left output mixer */
1675 if (res != 0)
1676 {
1677 wm8978_interface_debug_print("wm8978: set left dac output to left output mixer failed.\n");
1678 (void)wm8978_deinit(&gs_handle);
1679
1680 return 1;
1681 }
1682
1683 /* -15db */
1685 if (res != 0)
1686 {
1687 wm8978_interface_debug_print("wm8978: right bypass volume control to output channel mixer convert to register failed.\n");
1688 (void)wm8978_deinit(&gs_handle);
1689
1690 return 1;
1691 }
1692
1693 /* set right bypass volume control to output channel mixer */
1695 if (res != 0)
1696 {
1697 wm8978_interface_debug_print("wm8978: set right bypass volume control to output channel mixer failed.\n");
1698 (void)wm8978_deinit(&gs_handle);
1699
1700 return 1;
1701 }
1702
1703 /* disable right bypass path to right output mixer */
1705 if (res != 0)
1706 {
1707 wm8978_interface_debug_print("wm8978: set right bypass path to right output mixer failed.\n");
1708 (void)wm8978_deinit(&gs_handle);
1709
1710 return 1;
1711 }
1712
1713 /* enable right dac output to right output mixer */
1715 if (res != 0)
1716 {
1717 wm8978_interface_debug_print("wm8978: set right dac output to right output mixer failed.\n");
1718 (void)wm8978_deinit(&gs_handle);
1719
1720 return 1;
1721 }
1722
1723 /* disable left auxiliary input to left channel output mixer */
1725 if (res != 0)
1726 {
1727 wm8978_interface_debug_print("wm8978: set left auxiliary input to left channel output mixer failed.\n");
1728 (void)wm8978_deinit(&gs_handle);
1729
1730 return 1;
1731 }
1732
1733 /* -15db */
1735 if (res != 0)
1736 {
1737 wm8978_interface_debug_print("wm8978: aux left channel input to left mixer volume convert to register failed.\n");
1738 (void)wm8978_deinit(&gs_handle);
1739
1740 return 1;
1741 }
1742
1743 /* set aux left channel input to left mixer volume */
1745 if (res != 0)
1746 {
1747 wm8978_interface_debug_print("wm8978: set aux left channel input to left mixer volume failed.\n");
1748 (void)wm8978_deinit(&gs_handle);
1749
1750 return 1;
1751 }
1752
1753 /* disable right auxiliary input to right channel output mixer */
1755 if (res != 0)
1756 {
1757 wm8978_interface_debug_print("wm8978: set right auxiliary input to right channel output mixer failed.\n");
1758 (void)wm8978_deinit(&gs_handle);
1759
1760 return 1;
1761 }
1762
1763 /* -15db */
1765 if (res != 0)
1766 {
1767 wm8978_interface_debug_print("wm8978: aux right channel input to right mixer volume convert to register failed.\n");
1768 (void)wm8978_deinit(&gs_handle);
1769
1770 return 1;
1771 }
1772
1773 /* set aux right channel input to right mixer volume */
1775 if (res != 0)
1776 {
1777 wm8978_interface_debug_print("wm8978: set aux right channel input to right mixer volume failed.\n");
1778 (void)wm8978_deinit(&gs_handle);
1779
1780 return 1;
1781 }
1782
1783 /* enable left input pga update */
1785 if (res != 0)
1786 {
1787 wm8978_interface_debug_print("wm8978: set left input pga update failed.\n");
1788 (void)wm8978_deinit(&gs_handle);
1789
1790 return 1;
1791 }
1792
1793 /* disable left channel input pga zero cross */
1795 if (res != 0)
1796 {
1797 wm8978_interface_debug_print("wm8978: set left channel input pga zero cross failed.\n");
1798 (void)wm8978_deinit(&gs_handle);
1799
1800 return 1;
1801 }
1802
1803 /* disable left channel input pga mute */
1805 if (res != 0)
1806 {
1807 wm8978_interface_debug_print("wm8978: set left channel input pga mute failed.\n");
1808 (void)wm8978_deinit(&gs_handle);
1809
1810 return 1;
1811 }
1812
1813 /* -12db */
1814 res = wm8978_left_channel_input_pga_volume_convert_to_register(&gs_handle, -12.0f, &reg);
1815 if (res != 0)
1816 {
1817 wm8978_interface_debug_print("wm8978: left channel input pga volume convert to register failed.\n");
1818 (void)wm8978_deinit(&gs_handle);
1819
1820 return 1;
1821 }
1822
1823 /* set left channel input pga volume */
1824 res = wm8978_set_left_channel_input_pga_volume(&gs_handle, reg);
1825 if (res != 0)
1826 {
1827 wm8978_interface_debug_print("wm8978: set left channel input pga volume failed.\n");
1828 (void)wm8978_deinit(&gs_handle);
1829
1830 return 1;
1831 }
1832
1833 /* enable right input pga update */
1835 if (res != 0)
1836 {
1837 wm8978_interface_debug_print("wm8978: set right input pga update failed.\n");
1838 (void)wm8978_deinit(&gs_handle);
1839
1840 return 1;
1841 }
1842
1843 /* disable right channel input pga zero cross */
1845 if (res != 0)
1846 {
1847 wm8978_interface_debug_print("wm8978: set right channel input pga zero cross failed.\n");
1848 (void)wm8978_deinit(&gs_handle);
1849
1850 return 1;
1851 }
1852
1853 /* disable right channel input pga mute */
1855 if (res != 0)
1856 {
1857 wm8978_interface_debug_print("wm8978: set right channel input pga mute failed.\n");
1858 (void)wm8978_deinit(&gs_handle);
1859
1860 return 1;
1861 }
1862
1863 /* -12db */
1864 res = wm8978_right_channel_input_pga_volume_convert_to_register(&gs_handle, -12.0f, &reg);
1865 if (res != 0)
1866 {
1867 wm8978_interface_debug_print("wm8978: right channel input pga volume convert to register failed.\n");
1868 (void)wm8978_deinit(&gs_handle);
1869
1870 return 1;
1871 }
1872
1873 /* set right channel input pga volume */
1874 res = wm8978_set_right_channel_input_pga_volume(&gs_handle, reg);
1875 if (res != 0)
1876 {
1877 wm8978_interface_debug_print("wm8978: set right channel input pga volume failed.\n");
1878 (void)wm8978_deinit(&gs_handle);
1879
1880 return 1;
1881 }
1882
1883 /* enable lout2 update */
1884 res = wm8978_set_lout2_update(&gs_handle, WM8978_BOOL_TRUE);
1885 if (res != 0)
1886 {
1887 wm8978_interface_debug_print("wm8978: set lout2 update failed.\n");
1888 (void)wm8978_deinit(&gs_handle);
1889
1890 return 1;
1891 }
1892
1893 /* disable lout2 speaker volume zero cross */
1895 if (res != 0)
1896 {
1897 wm8978_interface_debug_print("wm8978: set lout2 speaker volume zero cross failed.\n");
1898 (void)wm8978_deinit(&gs_handle);
1899
1900 return 1;
1901 }
1902
1903 /* disable lout2 left speaker output mute */
1905 if (res != 0)
1906 {
1907 wm8978_interface_debug_print("wm8978: set lout2 left speaker output mute failed.\n");
1908 (void)wm8978_deinit(&gs_handle);
1909
1910 return 1;
1911 }
1912
1913 /* set default lout2 left speaker output volume */
1915 if (res != 0)
1916 {
1917 wm8978_interface_debug_print("wm8978: lout2 left speaker output volume convert to register failed.\n");
1918 (void)wm8978_deinit(&gs_handle);
1919
1920 return 1;
1921 }
1922
1923 /* set lout2 left speaker output volume */
1924 res = wm8978_set_lout2_left_speaker_output_volume(&gs_handle, reg);
1925 if (res != 0)
1926 {
1927 wm8978_interface_debug_print("wm8978: set lout2 left speaker output volume failed.\n");
1928 (void)wm8978_deinit(&gs_handle);
1929
1930 return 1;
1931 }
1932
1933 /* enable rout2 update */
1934 res = wm8978_set_rout2_update(&gs_handle, WM8978_BOOL_TRUE);
1935 if (res != 0)
1936 {
1937 wm8978_interface_debug_print("wm8978: set rout2 update failed.\n");
1938 (void)wm8978_deinit(&gs_handle);
1939
1940 return 1;
1941 }
1942
1943 /* disable rout2 speaker volume zero cross */
1945 if (res != 0)
1946 {
1947 wm8978_interface_debug_print("wm8978: set rout2 speaker volume zero cross failed.\n");
1948 (void)wm8978_deinit(&gs_handle);
1949
1950 return 1;
1951 }
1952
1953 /* disable rout2 right speaker output mute */
1955 if (res != 0)
1956 {
1957 wm8978_interface_debug_print("wm8978: set rout2 right speaker output mute failed.\n");
1958 (void)wm8978_deinit(&gs_handle);
1959
1960 return 1;
1961 }
1962
1963 /* set default rout2 right speaker output volume */
1965 if (res != 0)
1966 {
1967 wm8978_interface_debug_print("wm8978: rout2 right speaker output volume convert to register failed.\n");
1968 (void)wm8978_deinit(&gs_handle);
1969
1970 return 1;
1971 }
1972
1973 /* set rout2 right speaker output volume */
1974 res = wm8978_set_rout2_right_speaker_output_volume(&gs_handle, reg);
1975 if (res != 0)
1976 {
1977 wm8978_interface_debug_print("wm8978: set rout2 right speaker output volume failed.\n");
1978 (void)wm8978_deinit(&gs_handle);
1979
1980 return 1;
1981 }
1982
1983 /* enable lout1 update */
1984 res = wm8978_set_lout1_update(&gs_handle, WM8978_BOOL_TRUE);
1985 if (res != 0)
1986 {
1987 wm8978_interface_debug_print("wm8978: set lout1 update failed.\n");
1988 (void)wm8978_deinit(&gs_handle);
1989
1990 return 1;
1991 }
1992
1993 /* disable lout1 headphone volume zero cross */
1995 if (res != 0)
1996 {
1997 wm8978_interface_debug_print("wm8978: set lout1 headphone volume zero cross failed.\n");
1998 (void)wm8978_deinit(&gs_handle);
1999
2000 return 1;
2001 }
2002
2003 /* disable lout1 left headphone output mute */
2005 if (res != 0)
2006 {
2007 wm8978_interface_debug_print("wm8978: set lout1 left headphone output mute failed.\n");
2008 (void)wm8978_deinit(&gs_handle);
2009
2010 return 1;
2011 }
2012
2013 /* set default lout1 left headphone output volume */
2015 if (res != 0)
2016 {
2017 wm8978_interface_debug_print("wm8978: lout1 left headphone output volume convert to register failed.\n");
2018 (void)wm8978_deinit(&gs_handle);
2019
2020 return 1;
2021 }
2022
2023 /* set lout1 left headphone output volume */
2024 res = wm8978_set_lout1_left_headphone_output_volume(&gs_handle, reg);
2025 if (res != 0)
2026 {
2027 wm8978_interface_debug_print("wm8978: set lout1 left headphone output volume failed.\n");
2028 (void)wm8978_deinit(&gs_handle);
2029
2030 return 1;
2031 }
2032
2033 /* enable rout1 update */
2034 res = wm8978_set_rout1_update(&gs_handle, WM8978_BOOL_TRUE);
2035 if (res != 0)
2036 {
2037 wm8978_interface_debug_print("wm8978: set rout1 update failed.\n");
2038 (void)wm8978_deinit(&gs_handle);
2039
2040 return 1;
2041 }
2042
2043 /* disable rout1 headphone volume zero cross */
2045 if (res != 0)
2046 {
2047 wm8978_interface_debug_print("wm8978: set rout1 headphone volume zero cross failed.\n");
2048 (void)wm8978_deinit(&gs_handle);
2049
2050 return 1;
2051 }
2052
2053 /* disable rout1 right headphone output mute */
2055 if (res != 0)
2056 {
2057 wm8978_interface_debug_print("wm8978: set rout1 right headphone output mute failed.\n");
2058 (void)wm8978_deinit(&gs_handle);
2059
2060 return 1;
2061 }
2062
2063 /* set default set rout1 right headphone output volume */
2065 if (res != 0)
2066 {
2067 wm8978_interface_debug_print("wm8978: rout1 right headphone output volume convert to register failed.\n");
2068 (void)wm8978_deinit(&gs_handle);
2069
2070 return 1;
2071 }
2072
2073 /* set rout1 right headphone output volume */
2075 if (res != 0)
2076 {
2077 wm8978_interface_debug_print("wm8978: set rout1 right headphone output volume failed.\n");
2078 (void)wm8978_deinit(&gs_handle);
2079
2080 return 1;
2081 }
2082 }
2083 else
2084 {
2085 /* disable right channel dac */
2087 if (res != 0)
2088 {
2089 wm8978_interface_debug_print("wm8978: set right channel dac failed.\n");
2090 (void)wm8978_deinit(&gs_handle);
2091
2092 return 1;
2093 }
2094
2095 /* disable left channel dac */
2097 if (res != 0)
2098 {
2099 wm8978_interface_debug_print("wm8978: set left channel dac failed.\n");
2100 (void)wm8978_deinit(&gs_handle);
2101
2102 return 1;
2103 }
2104
2105 /* enable right channel adc */
2107 if (res != 0)
2108 {
2109 wm8978_interface_debug_print("wm8978: set right channel adc failed.\n");
2110 (void)wm8978_deinit(&gs_handle);
2111
2112 return 1;
2113 }
2114
2115 /* enable left channel adc */
2117 if (res != 0)
2118 {
2119 wm8978_interface_debug_print("wm8978: set left channel adc failed.\n");
2120 (void)wm8978_deinit(&gs_handle);
2121
2122 return 1;
2123 }
2124
2125 /* enable right channel input pga */
2127 if (res != 0)
2128 {
2129 wm8978_interface_debug_print("wm8978: set right channel input pga failed.\n");
2130 (void)wm8978_deinit(&gs_handle);
2131
2132 return 1;
2133 }
2134
2135 /* enable left channel input pga */
2137 if (res != 0)
2138 {
2139 wm8978_interface_debug_print("wm8978: set left channel input pga failed.\n");
2140 (void)wm8978_deinit(&gs_handle);
2141
2142 return 1;
2143 }
2144
2145 /* enable right channel input pga negative */
2147 if (res != 0)
2148 {
2149 wm8978_interface_debug_print("wm8978: set right channel input pga negative failed.\n");
2150 (void)wm8978_deinit(&gs_handle);
2151
2152 return 1;
2153 }
2154
2155 /* enable right channel input pga amplifier positive */
2157 if (res != 0)
2158 {
2159 wm8978_interface_debug_print("wm8978: set right channel input pga amplifier positive failed.\n");
2160 (void)wm8978_deinit(&gs_handle);
2161
2162 return 1;
2163 }
2164
2165 /* enable left channel input pga negative */
2167 if (res != 0)
2168 {
2169 wm8978_interface_debug_print("wm8978: set left channel input pga negative failed.\n");
2170 (void)wm8978_deinit(&gs_handle);
2171
2172 return 1;
2173 }
2174
2175 /* enable left channel input pga amplifier positive */
2177 if (res != 0)
2178 {
2179 wm8978_interface_debug_print("wm8978: set left channel input pga amplifier positive failed.\n");
2180 (void)wm8978_deinit(&gs_handle);
2181
2182 return 1;
2183 }
2184
2185 /* enable left channel input pga boost */
2187 if (res != 0)
2188 {
2189 wm8978_interface_debug_print("wm8978: set left channel input pga boost failed.\n");
2190 (void)wm8978_deinit(&gs_handle);
2191
2192 return 1;
2193 }
2194
2195 /* set default left channel input boost stage */
2197 if (res != 0)
2198 {
2199 wm8978_interface_debug_print("wm8978: left channel input boost stage convert to register failed.\n");
2200 (void)wm8978_deinit(&gs_handle);
2201
2202 return 1;
2203 }
2204
2205 /* set left channel input boost stage */
2206 res = wm8978_set_left_channel_input_boost_stage(&gs_handle, reg);
2207 if (res != 0)
2208 {
2209 wm8978_interface_debug_print("wm8978: set left channel input boost stage failed.\n");
2210 (void)wm8978_deinit(&gs_handle);
2211
2212 return 1;
2213 }
2214
2215 /* enable right channel input pga boost */
2217 if (res != 0)
2218 {
2219 wm8978_interface_debug_print("wm8978: set right channel input pga boost failed.\n");
2220 (void)wm8978_deinit(&gs_handle);
2221
2222 return 1;
2223 }
2224
2225 /* set default right channel input boost stage */
2227 if (res != 0)
2228 {
2229 wm8978_interface_debug_print("wm8978: right channel input boost stage convert to register failed.\n");
2230 (void)wm8978_deinit(&gs_handle);
2231
2232 return 1;
2233 }
2234
2235 /* set right channel input boost stage */
2236 res = wm8978_set_right_channel_input_boost_stage(&gs_handle, reg);
2237 if (res != 0)
2238 {
2239 wm8978_interface_debug_print("wm8978: set right channel input boost stage failed.\n");
2240 (void)wm8978_deinit(&gs_handle);
2241
2242 return 1;
2243 }
2244
2245 /* -15db */
2247 if (res != 0)
2248 {
2249 wm8978_interface_debug_print("wm8978: auxiliary amplifier left channel input boost stage convert to register failed.\n");
2250 (void)wm8978_deinit(&gs_handle);
2251
2252 return 1;
2253 }
2254
2255 /* set auxiliary amplifier left channel input boost stage */
2257 if (res != 0)
2258 {
2259 wm8978_interface_debug_print("wm8978: set auxiliary amplifier left channel input boost stage failed.\n");
2260 (void)wm8978_deinit(&gs_handle);
2261
2262 return 1;
2263 }
2264
2265 /* -15db */
2267 if (res != 0)
2268 {
2269 wm8978_interface_debug_print("wm8978: auxiliary amplifier right channel input boost stage convert to register failed.\n");
2270 (void)wm8978_deinit(&gs_handle);
2271
2272 return 1;
2273 }
2274
2275 /* set auxiliary amplifier right channel input boost stage */
2277 if (res != 0)
2278 {
2279 wm8978_interface_debug_print("wm8978: set auxiliary amplifier right channel input boost stage failed.\n");
2280 (void)wm8978_deinit(&gs_handle);
2281
2282 return 1;
2283 }
2284
2285 /* set default left bypass volume control to output channel mixer */
2288 &reg);
2289 if (res != 0)
2290 {
2291 wm8978_interface_debug_print("wm8978: left bypass volume control to output channel mixer convert to register failed.\n");
2292 (void)wm8978_deinit(&gs_handle);
2293
2294 return 1;
2295 }
2296
2297 /* set left bypass volume control to output channel mixer */
2299 if (res != 0)
2300 {
2301 wm8978_interface_debug_print("wm8978: set left bypass volume control to output channel mixer failed.\n");
2302 (void)wm8978_deinit(&gs_handle);
2303
2304 return 1;
2305 }
2306
2307 /* enable left bypass path to left output mixer */
2309 if (res != 0)
2310 {
2311 wm8978_interface_debug_print("wm8978: set left bypass path to left output mixer failed.\n");
2312 (void)wm8978_deinit(&gs_handle);
2313
2314 return 1;
2315 }
2316
2317 /* disable left dac output to left output mixer */
2319 if (res != 0)
2320 {
2321 wm8978_interface_debug_print("wm8978: set left dac output to left output mixer failed.\n");
2322 (void)wm8978_deinit(&gs_handle);
2323
2324 return 1;
2325 }
2326
2327 /* set default right bypass volume control to output channel mixer */
2330 &reg);
2331 if (res != 0)
2332 {
2333 wm8978_interface_debug_print("wm8978: right bypass volume control to output channel mixer convert to register failed.\n");
2334 (void)wm8978_deinit(&gs_handle);
2335
2336 return 1;
2337 }
2338
2339 /* set right bypass volume control to output channel mixer */
2341 if (res != 0)
2342 {
2343 wm8978_interface_debug_print("wm8978: set right bypass volume control to output channel mixer failed.\n");
2344 (void)wm8978_deinit(&gs_handle);
2345
2346 return 1;
2347 }
2348
2349 /* enable right bypass path to right output mixer */
2351 if (res != 0)
2352 {
2353 wm8978_interface_debug_print("wm8978: set right bypass path to right output mixer failed.\n");
2354 (void)wm8978_deinit(&gs_handle);
2355
2356 return 1;
2357 }
2358
2359 /* disable right dac output to right output mixer */
2361 if (res != 0)
2362 {
2363 wm8978_interface_debug_print("wm8978: set right dac output to right output mixer failed.\n");
2364 (void)wm8978_deinit(&gs_handle);
2365
2366 return 1;
2367 }
2368
2369 /* disable left auxiliary input to left channel output mixer */
2371 if (res != 0)
2372 {
2373 wm8978_interface_debug_print("wm8978: set left auxiliary input to left channel output mixer failed.\n");
2374 (void)wm8978_deinit(&gs_handle);
2375
2376 return 1;
2377 }
2378
2379 /* -15db */
2381 if (res != 0)
2382 {
2383 wm8978_interface_debug_print("wm8978: aux left channel input to left mixer volume convert to register failed.\n");
2384 (void)wm8978_deinit(&gs_handle);
2385
2386 return 1;
2387 }
2388
2389 /* set aux left channel input to left mixer volume */
2391 if (res != 0)
2392 {
2393 wm8978_interface_debug_print("wm8978: set aux left channel input to left mixer volume failed.\n");
2394 (void)wm8978_deinit(&gs_handle);
2395
2396 return 1;
2397 }
2398
2399 /* disable right auxiliary input to right channel output mixer */
2401 if (res != 0)
2402 {
2403 wm8978_interface_debug_print("wm8978: set right auxiliary input to right channel output mixer failed.\n");
2404 (void)wm8978_deinit(&gs_handle);
2405
2406 return 1;
2407 }
2408
2409 /* -15db */
2411 if (res != 0)
2412 {
2413 wm8978_interface_debug_print("wm8978: aux right channel input to right mixer volume convert to register failed.\n");
2414 (void)wm8978_deinit(&gs_handle);
2415
2416 return 1;
2417 }
2418
2419 /* set aux right channel input to right mixer volume */
2421 if (res != 0)
2422 {
2423 wm8978_interface_debug_print("wm8978: set aux right channel input to right mixer volume failed.\n");
2424 (void)wm8978_deinit(&gs_handle);
2425
2426 return 1;
2427 }
2428
2429 /* enable left input pga update */
2431 if (res != 0)
2432 {
2433 wm8978_interface_debug_print("wm8978: set left input pga update failed.\n");
2434 (void)wm8978_deinit(&gs_handle);
2435
2436 return 1;
2437 }
2438
2439 /* disable left channel input pga zero cross */
2441 if (res != 0)
2442 {
2443 wm8978_interface_debug_print("wm8978: set left channel input pga zero cross failed.\n");
2444 (void)wm8978_deinit(&gs_handle);
2445
2446 return 1;
2447 }
2448
2449 /* disable left channel input pga mute */
2451 if (res != 0)
2452 {
2453 wm8978_interface_debug_print("wm8978: set left channel input pga mute failed.\n");
2454 (void)wm8978_deinit(&gs_handle);
2455
2456 return 1;
2457 }
2458
2459 /* set default left channel input pga volume */
2461 if (res != 0)
2462 {
2463 wm8978_interface_debug_print("wm8978: left channel input pga volume convert to register failed.\n");
2464 (void)wm8978_deinit(&gs_handle);
2465
2466 return 1;
2467 }
2468
2469 /* set left channel input pga volume */
2470 res = wm8978_set_left_channel_input_pga_volume(&gs_handle, reg);
2471 if (res != 0)
2472 {
2473 wm8978_interface_debug_print("wm8978: set left channel input pga volume failed.\n");
2474 (void)wm8978_deinit(&gs_handle);
2475
2476 return 1;
2477 }
2478
2479 /* enable right input pga update */
2481 if (res != 0)
2482 {
2483 wm8978_interface_debug_print("wm8978: set right input pga update failed.\n");
2484 (void)wm8978_deinit(&gs_handle);
2485
2486 return 1;
2487 }
2488
2489 /* disable right channel input pga zero cross */
2491 if (res != 0)
2492 {
2493 wm8978_interface_debug_print("wm8978: set right channel input pga zero cross failed.\n");
2494 (void)wm8978_deinit(&gs_handle);
2495
2496 return 1;
2497 }
2498
2499 /* disable right channel input pga mute */
2501 if (res != 0)
2502 {
2503 wm8978_interface_debug_print("wm8978: set right channel input pga mute failed.\n");
2504 (void)wm8978_deinit(&gs_handle);
2505
2506 return 1;
2507 }
2508
2509 /* set default right channel input pga volume */
2511 if (res != 0)
2512 {
2513 wm8978_interface_debug_print("wm8978: right channel input pga volume convert to register failed.\n");
2514 (void)wm8978_deinit(&gs_handle);
2515
2516 return 1;
2517 }
2518
2519 /* set right channel input pga volume */
2520 res = wm8978_set_right_channel_input_pga_volume(&gs_handle, reg);
2521 if (res != 0)
2522 {
2523 wm8978_interface_debug_print("wm8978: set right channel input pga volume failed.\n");
2524 (void)wm8978_deinit(&gs_handle);
2525
2526 return 1;
2527 }
2528
2529 /* enable lout2 update */
2530 res = wm8978_set_lout2_update(&gs_handle, WM8978_BOOL_TRUE);
2531 if (res != 0)
2532 {
2533 wm8978_interface_debug_print("wm8978: set lout2 update failed.\n");
2534 (void)wm8978_deinit(&gs_handle);
2535
2536 return 1;
2537 }
2538
2539 /* disable lout2 speaker volume zero cross */
2541 if (res != 0)
2542 {
2543 wm8978_interface_debug_print("wm8978: set lout2 speaker volume zero cross failed.\n");
2544 (void)wm8978_deinit(&gs_handle);
2545
2546 return 1;
2547 }
2548
2549 /* disable lout2 left speaker output mute */
2551 if (res != 0)
2552 {
2553 wm8978_interface_debug_print("wm8978: set lout2 left speaker output mute failed.\n");
2554 (void)wm8978_deinit(&gs_handle);
2555
2556 return 1;
2557 }
2558
2559 /* -57db */
2561 if (res != 0)
2562 {
2563 wm8978_interface_debug_print("wm8978: lout2 left speaker output volume convert to register failed.\n");
2564 (void)wm8978_deinit(&gs_handle);
2565
2566 return 1;
2567 }
2568
2569 /* set lout2 left speaker output volume */
2570 res = wm8978_set_lout2_left_speaker_output_volume(&gs_handle, reg);
2571 if (res != 0)
2572 {
2573 wm8978_interface_debug_print("wm8978: set lout2 left speaker output volume failed.\n");
2574 (void)wm8978_deinit(&gs_handle);
2575
2576 return 1;
2577 }
2578
2579 /* enable rout2 update */
2580 res = wm8978_set_rout2_update(&gs_handle, WM8978_BOOL_TRUE);
2581 if (res != 0)
2582 {
2583 wm8978_interface_debug_print("wm8978: set rout2 update failed.\n");
2584 (void)wm8978_deinit(&gs_handle);
2585
2586 return 1;
2587 }
2588
2589 /* disable rout2 speaker volume zero cross */
2591 if (res != 0)
2592 {
2593 wm8978_interface_debug_print("wm8978: set rout2 speaker volume zero cross failed.\n");
2594 (void)wm8978_deinit(&gs_handle);
2595
2596 return 1;
2597 }
2598
2599 /* disable rout2 right speaker output mute */
2601 if (res != 0)
2602 {
2603 wm8978_interface_debug_print("wm8978: set rout2 right speaker output mute failed.\n");
2604 (void)wm8978_deinit(&gs_handle);
2605
2606 return 1;
2607 }
2608
2609 /* -57db */
2611 if (res != 0)
2612 {
2613 wm8978_interface_debug_print("wm8978: rout2 right speaker output volume convert to register failed.\n");
2614 (void)wm8978_deinit(&gs_handle);
2615
2616 return 1;
2617 }
2618
2619 /* set rout2 right speaker output volume */
2620 res = wm8978_set_rout2_right_speaker_output_volume(&gs_handle, reg);
2621 if (res != 0)
2622 {
2623 wm8978_interface_debug_print("wm8978: set rout2 right speaker output volume failed.\n");
2624 (void)wm8978_deinit(&gs_handle);
2625
2626 return 1;
2627 }
2628
2629 /* enable lout1 update */
2630 res = wm8978_set_lout1_update(&gs_handle, WM8978_BOOL_TRUE);
2631 if (res != 0)
2632 {
2633 wm8978_interface_debug_print("wm8978: set lout1 update failed.\n");
2634 (void)wm8978_deinit(&gs_handle);
2635
2636 return 1;
2637 }
2638
2639 /* disable lout1 headphone volume zero cross */
2641 if (res != 0)
2642 {
2643 wm8978_interface_debug_print("wm8978: set lout1 headphone volume zero cross failed.\n");
2644 (void)wm8978_deinit(&gs_handle);
2645
2646 return 1;
2647 }
2648
2649 /* disable lout1 left headphone output mute */
2651 if (res != 0)
2652 {
2653 wm8978_interface_debug_print("wm8978: set lout1 left headphone output mute failed.\n");
2654 (void)wm8978_deinit(&gs_handle);
2655
2656 return 1;
2657 }
2658
2659 /* -57db */
2661 if (res != 0)
2662 {
2663 wm8978_interface_debug_print("wm8978: lout1 left headphone output volume convert to register failed.\n");
2664 (void)wm8978_deinit(&gs_handle);
2665
2666 return 1;
2667 }
2668
2669 /* set lout1 left headphone output volume */
2670 res = wm8978_set_lout1_left_headphone_output_volume(&gs_handle, reg);
2671 if (res != 0)
2672 {
2673 wm8978_interface_debug_print("wm8978: set lout1 left headphone output volume failed.\n");
2674 (void)wm8978_deinit(&gs_handle);
2675
2676 return 1;
2677 }
2678
2679 /* enable rout1 update */
2680 res = wm8978_set_rout1_update(&gs_handle, WM8978_BOOL_TRUE);
2681 if (res != 0)
2682 {
2683 wm8978_interface_debug_print("wm8978: set rout1 update failed.\n");
2684 (void)wm8978_deinit(&gs_handle);
2685
2686 return 1;
2687 }
2688
2689 /* disable rout1 headphone volume zero cross */
2691 if (res != 0)
2692 {
2693 wm8978_interface_debug_print("wm8978: set rout1 headphone volume zero cross failed.\n");
2694 (void)wm8978_deinit(&gs_handle);
2695
2696 return 1;
2697 }
2698
2699 /* disable rout1 right headphone output mute */
2701 if (res != 0)
2702 {
2703 wm8978_interface_debug_print("wm8978: set rout1 right headphone output mute failed.\n");
2704 (void)wm8978_deinit(&gs_handle);
2705
2706 return 1;
2707 }
2708
2709 /* -57db */
2711 if (res != 0)
2712 {
2713 wm8978_interface_debug_print("wm8978: rout1 right headphone output volume convert to register failed.\n");
2714 (void)wm8978_deinit(&gs_handle);
2715
2716 return 1;
2717 }
2718
2719 /* set rout1 right headphone output volume */
2721 if (res != 0)
2722 {
2723 wm8978_interface_debug_print("wm8978: set rout1 right headphone output volume failed.\n");
2724 (void)wm8978_deinit(&gs_handle);
2725
2726 return 1;
2727 }
2728 }
2729
2730 return 0;
2731}
2732
2744{
2745 uint8_t res;
2746
2747 /* set dac companding */
2748 res = wm8978_set_dac_companding(&gs_handle, companding);
2749 if (res != 0)
2750 {
2751 return 1;
2752 }
2753
2754 /* set adc companding linear */
2755 res = wm8978_set_adc_companding(&gs_handle, companding);
2756 if (res != 0)
2757 {
2758 return 1;
2759 }
2760
2761 /* set channels */
2762 res = wm8978_set_channel(&gs_handle, channel);
2763 if (res != 0)
2764 {
2765 return 1;
2766 }
2767
2768 /* set word length */
2769 res = wm8978_set_word_length(&gs_handle, length);
2770 if (res != 0)
2771 {
2772 return 1;
2773 }
2774
2775 return 0;
2776}
2777
2786{
2787 uint8_t res;
2788
2789 /* deinit wm8978 */
2790 res = wm8978_deinit(&gs_handle);
2791 if (res != 0)
2792 {
2793 return 1;
2794 }
2795
2796 return 0;
2797}
2798
2808{
2809 uint8_t res;
2810 uint8_t reg;
2811
2812 /* convert volume */
2813 res = wm8978_volume_convert_to_register(&gs_handle, db, &reg);
2814 if (res != 0)
2815 {
2816 return 1;
2817 }
2818
2819 /* set dac left volume */
2820 res = wm8978_set_dac_left_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
2821 if (res != 0)
2822 {
2823 return 1;
2824 }
2825
2826 /* set dac right volume */
2827 res = wm8978_set_dac_right_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
2828 if (res != 0)
2829 {
2830 return 1;
2831 }
2832
2833 return 0;
2834}
2835
2844{
2845 uint8_t res;
2846
2847 /* set dac left volume */
2848 res = wm8978_set_dac_left_volume(&gs_handle, WM8978_BOOL_TRUE, 0x00);
2849 if (res != 0)
2850 {
2851 return 1;
2852 }
2853
2854 /* set dac right volume */
2855 res = wm8978_set_dac_right_volume(&gs_handle, WM8978_BOOL_TRUE, 0x00);
2856 if (res != 0)
2857 {
2858 return 1;
2859 }
2860
2861 return 0;
2862}
2863
2873{
2874 uint8_t res;
2875 uint8_t reg;
2876
2877 /* set default adc volume */
2878 res = wm8978_volume_convert_to_register(&gs_handle, db, &reg);
2879 if (res != 0)
2880 {
2881 return 1;
2882 }
2883
2884 /* set adc left volume */
2885 res = wm8978_set_adc_left_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
2886 if (res != 0)
2887 {
2888 return 1;
2889 }
2890
2891 /* set adc right volume */
2892 res = wm8978_set_adc_right_volume(&gs_handle, WM8978_BOOL_TRUE, reg);
2893 if (res != 0)
2894 {
2895 return 1;
2896 }
2897
2898 return 0;
2899}
driver wm8978 basic header file
uint8_t wm8978_set_lout2_left_speaker_output_volume(wm8978_handle_t *handle, uint8_t vol)
set lout2 left speaker output volume
uint8_t wm8978_set_right_out2(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right out2
uint8_t wm8978_set_microphone_bias(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable microphone bias
uint8_t wm8978_set_right_channel_adc(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel adc
uint8_t wm8978_left_bypass_volume_control_to_output_channel_mixer_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the left bypass volume control to output channel mixer to the register raw data
uint8_t wm8978_set_right_channel_input_pga_negative(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga negative
uint8_t wm8978_set_auxiliary_amplifier_left_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set auxiliary amplifier left channel input boost stage
uint8_t wm8978_set_microphone_bias_voltage(wm8978_handle_t *handle, wm8978_avdd_t avdd)
set microphone bias voltage
uint8_t wm8978_set_eq1_gain(wm8978_handle_t *handle, uint8_t gain)
set eq1 gain
uint8_t wm8978_lout1_left_headphone_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the lout1 left headphone output volume to the register raw data
uint8_t wm8978_set_equaliser_apply(wm8978_handle_t *handle, wm8978_equaliser_t equaliser)
set equaliser apply
uint8_t wm8978_set_notch_filter_a0_coefficient_bit_6_0(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a0 coefficient bit6 - bit0
uint8_t wm8978_set_mute_input_to_inv_rout2_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable mute input to inv rout2 mixer
uint8_t wm8978_set_eq4_gain(wm8978_handle_t *handle, uint8_t gain)
set eq4 gain
uint8_t wm8978_set_channel(wm8978_handle_t *handle, wm8978_channel_t channel)
set channel
uint8_t wm8978_set_lout1_headphone_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout1 headphone volume zero cross
uint8_t wm8978_set_adc_right_channel_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set adc right channel polarity
uint8_t wm8978_set_plln(wm8978_handle_t *handle, uint8_t n)
set plln
uint8_t wm8978_set_rout1_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout1 update
uint8_t wm8978_set_left_channel_input_pga_volume(wm8978_handle_t *handle, uint8_t volume)
set left channel input pga volume
uint8_t wm8978_set_word_length(wm8978_handle_t *handle, wm8978_word_length_t word_length)
set word length
uint8_t wm8978_set_right_dac_output_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set right dac output polarity
uint8_t wm8978_set_pll(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable pll
uint8_t wm8978_set_left_dac_output_to_right_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac output to right output mixer
uint8_t wm8978_set_vmid_0(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable vmid 0
uint8_t wm8978_set_alc(wm8978_handle_t *handle, wm8978_alc_t alc)
set alc
uint8_t wm8978_set_rout2_speaker_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout2 speaker volume zero cross
uint8_t wm8978_aux_right_channel_input_to_right_mixer_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the aux right channel input to right mixer volume to the register raw data
uint8_t wm8978_set_adc_appear(wm8978_handle_t *handle, wm8978_appear_t appear)
set adc appear
uint8_t wm8978_set_rout1_right_headphone_output_volume(wm8978_handle_t *handle, uint8_t vol)
set rout1 right headphone output volume
uint8_t wm8978_init(wm8978_handle_t *handle)
initialize the chip
uint8_t wm8978_set_right_channel_input_pga_volume(wm8978_handle_t *handle, uint8_t volume)
set right channel input pga volume
uint8_t wm8978_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
convert the volume data to the register raw data
uint8_t wm8978_set_gpio1_select(wm8978_handle_t *handle, wm8978_gpio1_sel_t sel)
set gpio1 select
uint8_t wm8978_set_right_dac_output_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac output to out4
uint8_t wm8978_set_left_channel_input_pga_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga boost
uint8_t wm8978_set_right_auxiliary_input_to_right_channel_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right auxiliary input to right channel output mixer
uint8_t wm8978_set_left_input_pga_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left input pga update
uint8_t wm8978_set_left_dac_mixer_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac mixer to out3
uint8_t wm8978_set_dac_left_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set dac left volume
uint8_t wm8978_set_eq4_bandwidth(wm8978_handle_t *handle, wm8978_eq_bandwidth_t width)
set eq4 bandwidth
uint8_t wm8978_set_adc_companding(wm8978_handle_t *handle, wm8978_companding_t companding)
set adc companding
uint8_t wm8978_auxiliary_amplifier_left_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the auxiliary amplifier left channel input boost stage to the register raw data
uint8_t wm8978_set_alc_level(wm8978_handle_t *handle, wm8978_alc_level_t level)
set alc level
uint8_t wm8978_set_right_bypass_path_to_right_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right bypass path to right output mixer
uint8_t wm8978_set_left_dac_output_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set left dac output polarity
uint8_t wm8978_set_right_channel_input_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input boost
uint8_t wm8978_set_right_output_channel_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right output channel mixer
uint8_t wm8978_auxiliary_amplifier_right_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the auxiliary amplifier right channel input boost stage to the register raw data
uint8_t wm8978_set_pll_div(wm8978_handle_t *handle, wm8978_pll_div_t d)
set pll div
uint8_t wm8978_eq_gain_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the eq gain to the register raw data
uint8_t wm8978_set_left_channel_input_pga_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga zero cross
uint8_t wm8978_set_eq5_gain(wm8978_handle_t *handle, uint8_t gain)
set eq5 gain
uint8_t wm8978_set_loopback(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable loopback
uint8_t wm8978_set_pll_freq(wm8978_handle_t *handle, uint32_t freq)
set pll freq
uint8_t wm8978_set_left_dac_mixer_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac mixer to out4
uint8_t wm8978_set_lrclk_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set lrclk polarity
uint8_t wm8978_set_dac_limiter_level(wm8978_handle_t *handle, wm8978_dac_limiter_level_t level)
set dac limiter level
uint8_t wm8978_alc_hold_time_convert_to_register(wm8978_handle_t *handle, float ms, uint8_t *reg)
convert the alc hold time to the register raw data
uint8_t wm8978_set_slow_clock(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable slow clock
uint8_t wm8978_set_approximate_sample_rate(wm8978_handle_t *handle, wm8978_approximate_sample_t sample)
set approximate sample rate
uint8_t wm8978_set_left_dac_output_to_left_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac output to left output mixer
uint8_t wm8978_set_eq5_cut_off(wm8978_handle_t *handle, wm8978_eq5_band_cut_off_t cut_off)
set eq5 cut off
uint8_t wm8978_set_lout2_speaker_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout2 speaker volume zero cross
uint8_t wm8978_set_eq2_gain(wm8978_handle_t *handle, uint8_t gain)
set eq2 gain
uint8_t wm8978_alc_noise_gate_threshold_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the alc noise gate threshold to the register raw data
uint8_t wm8978_set_amute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable amute
uint8_t wm8978_set_unused_input_output_tie_off_buffer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable unused input output tie off buffer
uint8_t wm8978_left_channel_input_pga_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
convert the left channel input pga volume to the register raw data
wm8978_companding_t
wm8978 companding enumeration definition
uint8_t wm8978_set_out3_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 boost
uint8_t wm8978_set_rout2_right_speaker_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout2 right speaker output mute
uint8_t wm8978_set_left_channel_input_pga_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga mute
uint8_t wm8978_set_left_out1(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left out1
uint8_t wm8978_left_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the left channel input boost stage to the register raw data
uint8_t wm8978_set_alc_noise_gate(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable alc noise gate
wm8978_word_length_t
wm8978 word length enumeration definition
uint8_t wm8978_set_out4_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mixer
wm8978_channel_t
wm8978 channel enumeration definition
uint8_t wm8978_set_lout2_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout2 update
uint8_t wm8978_set_right_bypass_volume_control_to_output_channel_mixer(wm8978_handle_t *handle, uint8_t vol)
set right bypass volume control to output channel mixer
uint8_t wm8978_depth_3d_convert_to_register(wm8978_handle_t *handle, float percent, uint8_t *reg)
convert the depth 3d to the register raw data
uint8_t wm8978_set_left_channel_input_pga_negative(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga negative
uint8_t wm8978_set_clock_mode(wm8978_handle_t *handle, wm8978_clock_mode_t mode)
set clock mode
uint8_t wm8978_set_vref_to_analogue_output_resistance(wm8978_handle_t *handle, wm8978_vref_t vref)
set vref to analogue output resistance
uint8_t wm8978_set_bclk_div(wm8978_handle_t *handle, wm8978_bclk_div_t d)
set bclk div
uint8_t wm8978_set_gpio1_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set gpio1 polarity
uint8_t wm8978_set_right_dac_output_to_left_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac output to left output mixer
uint8_t wm8978_set_right_dac_mixer_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac mixer to out4
uint8_t wm8978_set_adc_left_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set adc left volume
uint8_t wm8978_aux_left_channel_input_to_left_mixer_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the aux left channel input to left mixer volume to the register raw data
uint8_t wm8978_set_left_bypass_volume_control_to_output_channel_mixer(wm8978_handle_t *handle, uint8_t vol)
set left bypass volume control to output channel mixer
uint8_t wm8978_set_left_channel_input_pga_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga positive
uint8_t wm8978_set_adc_left_channel_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set adc left channel polarity
uint8_t wm8978_set_speaker_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable speaker boost
uint8_t wm8978_set_eq3_bandwidth(wm8978_handle_t *handle, wm8978_eq_bandwidth_t width)
set eq3 bandwidth
uint8_t wm8978_rout1_right_headphone_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the rout1 right headphone output volume to the register raw data
uint8_t wm8978_set_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4
uint8_t wm8978_set_adc_oversample_rate(wm8978_handle_t *handle, wm8978_adc_oversample_rate_t rate)
set adc oversample rate
uint8_t wm8978_set_depth_3d(wm8978_handle_t *handle, uint8_t depth)
set depth 3d
uint8_t wm8978_set_clksel(wm8978_handle_t *handle, wm8978_clksel_t clksel)
set clksel
uint8_t wm8978_set_dac_oversample_rate(wm8978_handle_t *handle, wm8978_dac_oversample_rate_t rate)
set dac oversample rate
uint8_t wm8978_set_out4_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mute
uint8_t wm8978_set_left_out2(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left out2
uint8_t wm8978_set_adc_right_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set adc right volume
uint8_t wm8978_set_thermal_shutdown(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable thermal shutdown
uint8_t wm8978_set_reference_impedance(wm8978_handle_t *handle, wm8978_impedance_t impedance)
set reference impedance
uint8_t wm8978_right_channel_input_boost_stage_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the right channel input boost stage to the register raw data
uint8_t wm8978_set_eq2_centre_freq(wm8978_handle_t *handle, wm8978_eq2_band_centre_freq_t freq)
set eq2 centre freq
uint8_t wm8978_set_left_channel_dac(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel dac
uint8_t wm8978_set_rout2_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout2 update
struct wm8978_handle_s wm8978_handle_t
wm8978 handle structure definition
uint8_t wm8978_set_dac_limiter_decay(wm8978_handle_t *handle, wm8978_dac_limiter_decay_t decay)
set dac limiter decay
uint8_t wm8978_lout2_left_speaker_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the lout2 left speaker output volume to the register raw data
uint8_t wm8978_set_right_channel_input_pga_amplifier_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga amplifier positive
uint8_t wm8978_set_alc_noise_gate_threshold(wm8978_handle_t *handle, uint8_t threshold)
set alc noise gate threshold
uint8_t wm8978_set_dac_companding(wm8978_handle_t *handle, wm8978_companding_t companding)
set dac companding
uint8_t wm8978_set_inv_rout2_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable inv rout2 mixer
uint8_t wm8978_set_out4_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 boost
uint8_t wm8978_set_right_input_pga_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right input pga update
uint8_t wm8978_set_out3_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 mixer
uint8_t wm8978_set_rout2_right_speaker_output_volume(wm8978_handle_t *handle, uint8_t vol)
set rout2 right speaker output volume
uint8_t wm8978_set_left_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set left channel input boost stage
uint8_t wm8978_set_right_adc_input_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right adc input to out4
uint8_t wm8978_set_left_auxiliary_input_to_left_channel_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left auxiliary input to left channel output mixer
uint8_t wm8978_set_left_dac_to_out4(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac to out4
uint8_t wm8978_set_left_output_channel_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left output channel mixer
uint8_t wm8978_set_alc_hold_time(wm8978_handle_t *handle, uint8_t t)
set alc hold time
uint8_t wm8978_set_eq1_cut_off(wm8978_handle_t *handle, wm8978_eq1_band_cut_off_t cut_off)
set eq1 cut off
uint8_t wm8978_set_left_bypass_path_to_left_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left bypass path to left output mixer
uint8_t wm8978_set_eq4_centre_freq(wm8978_handle_t *handle, wm8978_eq4_band_centre_freq_t freq)
set eq4 centre freq
uint8_t wm8978_rout2_right_speaker_output_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the rout2 right speaker output volume to the register raw data
uint8_t wm8978_set_alc_max_gain(wm8978_handle_t *handle, wm8978_max_gain_t gain)
set alc max gain
uint8_t wm8978_set_mclk_div(wm8978_handle_t *handle, wm8978_mclk_div_t d)
set mclk div
uint8_t wm8978_set_lout2_left_speaker_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout2 left speaker output mute
uint8_t wm8978_set_lout1_left_headphone_output_volume(wm8978_handle_t *handle, uint8_t vol)
set lout1 left headphone output volume
uint8_t wm8978_set_sleep(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable sleep
uint8_t wm8978_set_notch_filter_a1_coefficient_bit_13_7(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a1 coefficient bit13 - bit7
uint8_t wm8978_set_alc_attack(wm8978_handle_t *handle, uint8_t attack)
set alc attack
uint8_t wm8978_set_out4_attenuated_by_6db(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 attenuated by 6db
uint8_t wm8978_set_aux_right_channel_input_to_right_mixer_volume(wm8978_handle_t *handle, uint8_t vol)
set aux right channel input to right mixer volume
uint8_t wm8978_set_notch_filter_a0_coefficient_bit_13_7(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a0 coefficient bit13 - bit7
uint8_t wm8978_right_channel_input_pga_volume_convert_to_register(wm8978_handle_t *handle, float db, uint8_t *reg)
convert the right channel input pga volume to the register raw data
uint8_t wm8978_set_out3_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3 mute
uint8_t wm8978_set_eq2_bandwidth(wm8978_handle_t *handle, wm8978_eq_bandwidth_t width)
set eq2 bandwidth
uint8_t wm8978_set_right_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set right channel input boost stage
uint8_t wm8978_set_dac_appear(wm8978_handle_t *handle, wm8978_appear_t appear)
set dac appear
uint8_t wm8978_set_right_channel_input_pga_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga boost
uint8_t wm8978_set_companding_8bit_mode(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable companding 8bit mode
uint8_t wm8978_set_left_adc_input_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left adc input to out3
uint8_t wm8978_set_beep_volume(wm8978_handle_t *handle, uint8_t vol)
set beep volume
uint8_t wm8978_set_dac_digital_limiter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable dac digital limiter
uint8_t wm8978_set_right_channel_input_pga_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga zero cross
uint8_t wm8978_set_beep(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable beep
uint8_t wm8978_set_eq3_gain(wm8978_handle_t *handle, uint8_t gain)
set eq3 gain
uint8_t wm8978_set_dc_buffer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable dc buffer
uint8_t wm8978_deinit(wm8978_handle_t *handle)
close the chip
uint8_t wm8978_set_rout1_right_headphone_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout1 right headphone output mute
uint8_t wm8978_set_vmid_1(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable vmid 1
uint8_t wm8978_set_right_out1(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right out1
uint8_t wm8978_set_dac_limiter_volume_boost(wm8978_handle_t *handle, uint8_t db)
set dac limiter volume boost
uint8_t wm8978_set_out4_mixer_output_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out4 mixer output to out3
uint8_t wm8978_set_bclk_polarity(wm8978_handle_t *handle, wm8978_polarity_t polarity)
set bclk polarity
uint8_t wm8978_set_alc_min_gain(wm8978_handle_t *handle, wm8978_min_gain_t gain)
set alc min gain
uint8_t wm8978_set_jack_logic_1(wm8978_handle_t *handle, wm8978_jack_t jack, wm8978_bool_t enable)
set jack logic 1
uint8_t wm8978_set_analogue_amplifier_bias(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable analogue amplifier bias
uint8_t wm8978_set_rout1_headphone_volume_zero_cross(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable rout1 headphone volume zero cross
uint8_t wm8978_set_left_channel_input_pga_amplifier_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga amplifier positive
uint8_t wm8978_set_mode(wm8978_handle_t *handle, wm8978_mode_t mode)
set chip mode
uint8_t wm8978_set_high_pass_filter_cut_off(wm8978_handle_t *handle, wm8978_high_pass_filter_cut_off_t cut)
set high pass filter cut off
uint8_t wm8978_set_left_channel_input_boost(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input boost
uint8_t wm8978_set_jack_detection(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable jack detection
uint8_t wm8978_set_left_channel_input_pga(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel input pga
uint8_t wm8978_set_alc_mode(wm8978_handle_t *handle, wm8978_alc_mode_t mode)
set alc mode
uint8_t wm8978_set_right_channel_input_pga(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga
uint8_t wm8978_set_auxiliary_amplifier_right_channel_input_boost_stage(wm8978_handle_t *handle, uint8_t stage)
set auxiliary amplifier right channel input boost stage
uint8_t wm8978_set_lout1_update(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout1 update
uint8_t wm8978_set_high_pass_filter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable high pass filter
uint8_t wm8978_set_right_channel_input_pga_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga mute
uint8_t wm8978_set_dac_limiter_attack(wm8978_handle_t *handle, wm8978_dac_limiter_attack_t attack)
set dac limiter attack
uint8_t wm8978_set_data_format(wm8978_handle_t *handle, wm8978_data_format_t format)
set data format
uint8_t wm8978_beep_volume_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the beep volume to the register raw data
uint8_t wm8978_set_soft_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable soft mute
uint8_t wm8978_set_right_channel_input_pga_positive(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel input pga positive
uint8_t wm8978_set_mclk_divide_by_2(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable mclk divide by 2
uint8_t wm8978_set_left_channel_adc(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left channel adc
uint8_t wm8978_set_aux_left_channel_input_to_left_mixer_volume(wm8978_handle_t *handle, uint8_t vol)
set aux left channel input to left mixer volume
uint8_t wm8978_set_left_dac_output_to_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable left dac output to out3
uint8_t wm8978_set_dac_right_volume(wm8978_handle_t *handle, wm8978_bool_t enable, uint8_t volume)
set dac right volume
uint8_t wm8978_set_notch_filter(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable notch filter
uint8_t wm8978_set_jack_logic_0(wm8978_handle_t *handle, wm8978_jack_t jack, wm8978_bool_t enable)
set jack logic 0
uint8_t wm8978_right_bypass_volume_control_to_output_channel_mixer_convert_to_register(wm8978_handle_t *handle, int8_t db, uint8_t *reg)
convert the right bypass volume control to output channel mixer to the register raw data
uint8_t wm8978_set_eq3_centre_freq(wm8978_handle_t *handle, wm8978_eq3_band_centre_freq_t freq)
set eq3 centre freq
uint8_t wm8978_set_lout1_left_headphone_output_mute(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable lout1 left headphone output mute
uint8_t wm8978_set_jack_gpio(wm8978_handle_t *handle, wm8978_jack_sel_t sel)
set jack gpio
uint8_t wm8978_set_right_dac_output_to_right_output_mixer(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right dac output to right output mixer
uint8_t wm8978_set_right_channel_dac(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable right channel dac
uint8_t wm8978_set_alc_decay(wm8978_handle_t *handle, uint8_t decay)
set alc decay
uint8_t wm8978_set_notch_filter_a1_coefficient_bit_6_0(wm8978_handle_t *handle, wm8978_bool_t update_once, uint8_t coefficient)
set notch filter a1 coefficient bit6 - bit0
uint8_t wm8978_set_out3(wm8978_handle_t *handle, wm8978_bool_t enable)
enable or disable out3
@ WM8978_JACK_OUT1
@ WM8978_JACK_OUT4
@ WM8978_JACK_OUT3
@ WM8978_JACK_OUT2
@ WM8978_BOOL_FALSE
@ WM8978_BOOL_TRUE
#define WM8978_BASIC_DEFAULT_ALC_ATTACK
#define WM8978_BASIC_DEFAULT_ALC_NOISE_GATE_THRESHOLD
#define WM8978_BASIC_DEFAULT_LEFT_DAC_OUTPUT_TO_OUT3
#define WM8978_BASIC_DEFAULT_RIGHT_CHANNEL_INPUT_PGA_POSITIVE
#define WM8978_BASIC_DEFAULT_JACK_GPIO
#define WM8978_BASIC_DEFAULT_LOUT2_LEFT_SPEAKER_OUTPUT_VOLUME
#define WM8978_BASIC_DEFAULT_DAC_LIMITER_DECAY
#define WM8978_BASIC_DEFAULT_LEFT_DAC_OUTPUT_POLARITY
#define WM8978_BASIC_DEFAULT_ADC_VOLUME
#define WM8978_BASIC_DEFAULT_OUT4_MUTE
#define WM8978_BASIC_DEFAULT_EQ4_BAND_CENTRE_FREQ
#define WM8978_BASIC_DEFAULT_VREF
uint8_t wm8978_basic_set_dac_mute(void)
basic example set dac mute
#define WM8978_BASIC_DEFAULT_OUT4_MIXER_OUTPUT_TO_OUT3
#define WM8978_BASIC_DEFAULT_DAC_DIGITAL_LIMITER
#define WM8978_BASIC_DEFAULT_BEEP
#define WM8978_BASIC_DEFAULT_ALC_MIN_GAIN
#define WM8978_BASIC_DEFAULT_RIGHT_CHANNEL_INPUT_BOOST
#define WM8978_BASIC_DEFAULT_RIGHT_OUTPUT_CHANNEL_MIXER
uint8_t wm8978_basic_set_dac_volume(float db)
basic example set dac volume
#define WM8978_BASIC_DEFAULT_RIGHT_DAC_MIXER_TO_OUT4
#define WM8978_BASIC_DEFAULT_DAC_OVERSAMPLE_RATE
#define WM8978_BASIC_DEFAULT_LEFT_OUTPUT_CHANNEL_MIXER
#define WM8978_BASIC_DEFAULT_THERMAL_SHUTDOWN
#define WM8978_BASIC_DEFAULT_OUT3_MIXER
#define WM8978_BASIC_DEFAULT_EQ5_BAND_CUT_OFF
#define WM8978_BASIC_DEFAULT_MICROPHONE_BIAS
#define WM8978_BASIC_DEFAULT_SPEAKER_BOOST
#define WM8978_BASIC_DEFAULT_MCLK_DIV
#define WM8978_BASIC_DEFAULT_REFERENCE_IMPEDANCE
#define WM8978_BASIC_DEFAULT_LEFT_DAC_TO_OUT4
#define WM8978_BASIC_DEFAULT_LEFT_BYPASS_VOLUME_CONTROL_TO_OUTPUT_CHANNEL_MIXER
#define WM8978_BASIC_DEFAULT_DAC_APPEAR
#define WM8978_BASIC_DEFAULT_JACK_DETECTION
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_0_OUT2
#define WM8978_BASIC_DEFAULT_DEPTH_3D
#define WM8978_BASIC_DEFAULT_DAC_VOLUME
#define WM8978_BASIC_DEFAULT_NOTCH_FILTER_A1_BIT_16_0
#define WM8978_BASIC_DEFAULT_BCLK_POLARITY
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_0_OUT4
#define WM8978_BASIC_DEFAULT_OUT4_ATTENUATED_BY_6DB
#define WM8978_BASIC_DEFAULT_ADC_RIGHT_CHANNEL_POLARITY
#define WM8978_BASIC_DEFAULT_EQ4_GAIN
#define WM8978_BASIC_DEFAULT_RIGHT_DAC_OUTPUT_TO_LEFT_OUTPUT_MIXER
#define WM8978_BASIC_DEFAULT_RIGHT_OUT2
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_0_OUT3
#define WM8978_BASIC_DEFAULT_NOTCH_FILTER_A0_BIT_16_0
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_0_OUT1
#define WM8978_BASIC_DEFAULT_RIGHT_BYPASS_VOLUME_CONTROL_TO_OUTPUT_CHANNEL_MIXER
#define WM8978_BASIC_DEFAULT_LEFT_DAC_MIXER_TO_OUT3
#define WM8978_BASIC_DEFAULT_OUT3_MUTE
#define WM8978_BASIC_DEFAULT_EQUALISER_APPLY
#define WM8978_BASIC_DEFAULT_ALC
#define WM8978_BASIC_DEFAULT_EQ5_GAIN
#define WM8978_BASIC_DEFAULT_LOOP_BACK
#define WM8978_BASIC_DEFAULT_RIGHT_CHANNEL_INPUT_BOOST_STATA
#define WM8978_BASIC_DEFAULT_EQ3_BAND_CENTRE_FREQ
#define WM8978_BASIC_DEFAULT_DAC_LIMITER_ATTACK
#define WM8978_BASIC_DEFAULT_ALC_MAX_GAIN
#define WM8978_BASIC_DEFAULT_HIGH_PASS_FILTER_CUT_OFF
#define WM8978_BASIC_DEFAULT_EQ1_GAIN
#define WM8978_BASIC_DEFAULT_EQ2_GAIN
#define WM8978_BASIC_DEFAULT_RIGHT_DAC_OUTPUT_POLARITY
#define WM8978_BASIC_DEFAULT_RIGHT_CHANNEL_INPUT_PGA_VOLUME
#define WM8978_BASIC_DEFAULT_CLOCK_MODE
#define WM8978_BASIC_DEFAULT_LEFT_CHANNEL_INPUT_PGA_VOLUME
#define WM8978_BASIC_DEFAULT_RIGHT_ADC_INPUT_TO_OUT4
#define WM8978_BASIC_DEFAULT_LEFT_CHANNEL_INPUT_PGA_POSITIVE
#define WM8978_BASIC_DEFAULT_ADC_APPEAR
#define WM8978_BASIC_DEFAULT_ADC_OVERSAMPLE_RATE
#define WM8978_BASIC_DEFAULT_MUTE_INPUT_TO_INV_ROUT2_MIXER
#define WM8978_BASIC_DEFAULT_INV_ROUT2_MIXER
#define WM8978_BASIC_DEFAULT_SLOW_CLOCK
#define WM8978_BASIC_DEFAULT_LOUT1_LEFT_HEADPHONE_OUTPUT_VOLUME
uint8_t wm8978_basic_init(wm8978_basic_mode_t mode)
basic example init
#define WM8978_BASIC_DEFAULT_OUT3
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_1_OUT1
#define WM8978_BASIC_DEFAULT_BEEP_VOLUME
#define WM8978_BASIC_DEFAULT_MODE
#define WM8978_BASIC_DEFAULT_EQ3_GAIN
#define WM8978_BASIC_DEFAULT_LOUT2_RIGHT_SPEAKER_OUTPUT_VOLUME
#define WM8978_BASIC_DEFAULT_LRCLK_POLARITY
#define WM8978_BASIC_DEFAULT_MICROPHONE_BIAS_VOLTAGE
#define WM8978_BASIC_DEFAULT_CLKSEL
#define WM8978_BASIC_DEFAULT_LEFT_DAC_OUTPUT_TO_RIGHT_OUTPUT_MIXER
#define WM8978_BASIC_DEFAULT_MCLK_DIVIDE_BY_2
#define WM8978_BASIC_DEFAULT_ANALOGUE_AMPLIFIER_BIAS
#define WM8978_BASIC_DEFAULT_LEFT_DAC_MIXER_TO_OUT4
#define WM8978_BASIC_DEFAULT_LEFT_CHANNEL_INPUT_BOOST
#define WM8978_BASIC_DEFAULT_ALC_MODE
#define WM8978_BASIC_DEFAULT_HIGH_PASS_FILTER
#define WM8978_BASIC_DEFAULT_ALC_LEVEL
wm8978_basic_mode_t
wm8978 basic mode enumeration definition
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_1_OUT4
#define WM8978_BASIC_DEFAULT_UNUSED_INPUT_OUTPUT_TIE_OFF_BUFFER
uint8_t wm8978_basic_config(wm8978_companding_t companding, wm8978_channel_t channel, wm8978_word_length_t length)
basic example config
#define WM8978_BASIC_DEFAULT_APPROXIMATE_SAMPLE
#define WM8978_BASIC_DEFAULT_NOTCH_FILTER_A1_BIT_13_7
#define WM8978_BASIC_DEFAULT_DAC_LIMITER_LEVEL
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_1_OUT3
#define WM8978_BASIC_DEFAULT_LOUT1_RIGHT_HEADPHONE_OUTPUT_VOLUME
#define WM8978_BASIC_DEFAULT_GPIO1_SELECT
uint8_t wm8978_basic_set_adc_volume(float db)
basic example set adc volume
#define WM8978_BASIC_DEFAULT_PLL_FREQ
#define WM8978_BASIC_DEFAULT_DC_BUFFER
wm8978 basic example default definition
#define WM8978_BASIC_DEFAULT_OUT4_MIXER
#define WM8978_BASIC_DEFAULT_RIGHT_OUT1
#define WM8978_BASIC_DEFAULT_VMID_1
#define WM8978_BASIC_DEFAULT_LEFT_OUT2
#define WM8978_BASIC_DEFAULT_NOTCH_FILTER_A0_BIT_13_7
#define WM8978_BASIC_DEFAULT_EQ4_BANDWIDTH
#define WM8978_BASIC_DEFAULT_SOFT_MUTE
#define WM8978_BASIC_DEFAULT_ALC_NOISE_GATE
#define WM8978_BASIC_DEFAULT_LEFT_ADC_INPUT_TO_OUT3
#define WM8978_BASIC_DEFAULT_EQ2_BAND_CENTRE_FREQ
#define WM8978_BASIC_DEFAULT_ALC_HOLD_TIME
#define WM8978_BASIC_DEFAULT_EQ1_BAND_CUT_OFF
#define WM8978_BASIC_DEFAULT_PLLN
#define WM8978_BASIC_DEFAULT_DATA_FORMAT
#define WM8978_BASIC_DEFAULT_DAC_LIMITER_VOLUME_BOOST
#define WM8978_BASIC_DEFAULT_EQ3_BANDWIDTH
#define WM8978_BASIC_DEFAULT_LEFT_OUT1
#define WM8978_BASIC_DEFAULT_OUT4
#define WM8978_BASIC_DEFAULT_OUT4_BOOST
#define WM8978_BASIC_DEFAULT_RIGHT_DAC_OUTPUT_TO_OUT4
#define WM8978_BASIC_DEFAULT_VMID_0
#define WM8978_BASIC_DEFAULT_OUT3_BOOST
#define WM8978_BASIC_DEFAULT_GPIO1_POLARITY
#define WM8978_BASIC_DEFAULT_ADC_LEFT_CHANNEL_POLARITY
#define WM8978_BASIC_DEFAULT_COMPANDING_8BIT_MODE
#define WM8978_BASIC_DEFAULT_PLL_DIV
#define WM8978_BASIC_DEFAULT_ALC_DECAY
#define WM8978_BASIC_DEFAULT_AMUTE
#define WM8978_BASIC_DEFAULT_EQ2_BANDWIDTH
#define WM8978_BASIC_DEFAULT_JACK_LOGIC_1_OUT2
#define WM8978_BASIC_DEFAULT_LEFT_CHANNEL_INPUT_BOOST_STATA
#define WM8978_BASIC_DEFAULT_PLL
#define WM8978_BASIC_DEFAULT_NOTCH_FILTER
#define WM8978_BASIC_DEFAULT_BCLK_DIV
uint8_t wm8978_basic_deinit(void)
basic example deinit
@ WM8978_BASIC_MODE_PLAY
void wm8978_interface_debug_print(const char *const fmt,...)
interface print format data
void wm8978_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t wm8978_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t wm8978_interface_iic_init(void)
interface iic bus init
uint8_t wm8978_interface_iic_deinit(void)
interface iic bus deinit