1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Index: wm8975.c
===================================================================
--- wm8975.c	(revision 28539)
+++ wm8975.c	(working copy)
@@ -53,7 +53,7 @@
     [LINVOL]   = LINVOL_LZCEN | 23, /* 0dB */
     [RINVOL]   = RINVOL_RIVU | RINVOL_RZCEN | 23, /* 0dB */
     [DAPCTRL]  = DAPCTRL_DACMU,
-    [PWRMGMT1] = PWRMGMT1_VMIDSEL_5K | PWRMGMT1_VREF,
+    [PWRMGMT1] = PWRMGMT1_VMIDSEL_500K | PWRMGMT1_VREF,
     [PWRMGMT2] = PWRMGMT2_DACL | PWRMGMT2_DACR | PWRMGMT2_LOUT1 
                  | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2,
 };
@@ -128,50 +128,30 @@

 void audiohw_preinit(void)
 {
-    /* POWER UP SEQUENCE */
     wmcodec_write(RESET, RESET_RESET);

-    /* 2. Enable Vmid and VREF, quick startup. */
-    wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
-    sleep(HZ/50);
-    wm8975_regs[PWRMGMT1] &= ~PWRMGMT1_VMIDSEL_MASK;
-    wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1] | PWRMGMT1_VMIDSEL_50K);
-    
-    /* 4. Enable DACs, line and headphone output buffers as required. */
-    wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
-    
     wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_LRP_I2S_RLO
                          | AINTFCE_IWL_16BIT | AINTFCE_FORMAT_I2S);

-    wm8975_write(DAPCTRL, wm8975_regs[DAPCTRL] );
-
-/* Still need to find out why this is neccessary */
-#ifdef IPOD_NANO2G
-    wmcodec_write(SAMPCTRL, 0);
-#else
+#ifndef IPOD_NANO2G
     wmcodec_write(SAMPCTRL, WM8975_44100HZ);
 #endif

-    /* set the volume to -6dB */
-    wmcodec_write(LOUT1VOL, LOUT1VOL_LO1ZC | IPOD_PCM_LEVEL);
-    wmcodec_write(ROUT1VOL, ROUT1VOL_RO1VU | ROUT1VOL_RO1ZC | IPOD_PCM_LEVEL);
+    wmcodec_write(LOUTMIX1, LOUTMIX1_LD2LO | LOUTMIX1_LI2LOVOL(5));
+    wmcodec_write(ROUTMIX2, ROUTMIX2_RD2RO | ROUTMIX2_RI2ROVOL(5));

-    wmcodec_write(LOUTMIX1, LOUTMIX1_LD2LO| LOUTMIX1_LI2LOVOL(5));
-    wmcodec_write(LOUTMIX2, LOUTMIX2_RI2LOVOL(5));
-    
-    wmcodec_write(ROUTMIX1, ROUTMIX1_LI2ROVOL(5));
-    wmcodec_write(ROUTMIX2, ROUTMIX2_RD2RO| ROUTMIX2_RI2ROVOL(5));
-    
-    wmcodec_write(MOUTMIX1, 0);
-    wmcodec_write(MOUTMIX2, 0);
+    wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
+    wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
 }

 void audiohw_postinit(void)
 {
+    wm8975_regs[PWRMGMT1] &= ~PWRMGMT1_VMIDSEL_MASK;
+    wm8975_regs[PWRMGMT1] |= PWRMGMT1_VMIDSEL_50K;
+    wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
     audiohw_mute(false);
 }

-
 void audiohw_set_master_vol(int vol_l, int vol_r)
 {
     /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */