diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-11-26 14:25:45 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-11-26 14:25:45 +0000 |
commit | 888451fb0f3f8b8a3e6e81a087e4545eeba7a774 (patch) | |
tree | c10cba5f31fd4b0e33d1c54c43289247aa6f6590 /firmware/drivers/audio | |
parent | e73383ea324e5f86105cc74983a88452bb261033 (diff) | |
download | rockbox-888451fb0f3f8b8a3e6e81a087e4545eeba7a774.tar.gz rockbox-888451fb0f3f8b8a3e6e81a087e4545eeba7a774.zip |
Get rid of remaining audiohw_enable_output style codec setup and use pre/post split initialization. Move some SoC-specific code like i2s_reset out of the codec drivers. Helps to unify drivers and it was only ever used to enable. I cannot possibly test everything so report (I'll be on call ;) or fix problems if any crop up.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19228 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/audio')
-rw-r--r-- | firmware/drivers/audio/tsc2100.c | 11 | ||||
-rw-r--r-- | firmware/drivers/audio/uda1380.c | 14 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8721.c | 50 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8731.c | 3 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8751.c | 1 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8758.c | 3 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8975.c | 3 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8985.c | 75 |
8 files changed, 57 insertions, 103 deletions
diff --git a/firmware/drivers/audio/tsc2100.c b/firmware/drivers/audio/tsc2100.c index 038f3ed178..e0e2c53e69 100644 --- a/firmware/drivers/audio/tsc2100.c +++ b/firmware/drivers/audio/tsc2100.c | |||
@@ -90,16 +90,7 @@ void audiohw_init(void) | |||
90 | 90 | ||
91 | void audiohw_postinit(void) | 91 | void audiohw_postinit(void) |
92 | { | 92 | { |
93 | } | 93 | audiohw_mute(0); |
94 | |||
95 | /* Silently enable / disable audio output */ | ||
96 | void audiohw_enable_output(bool enable) | ||
97 | { | ||
98 | if (enable) { | ||
99 | audiohw_mute(0); | ||
100 | } else { | ||
101 | audiohw_mute(1); | ||
102 | } | ||
103 | } | 94 | } |
104 | 95 | ||
105 | void audiohw_set_master_vol(int vol_l, int vol_r) | 96 | void audiohw_set_master_vol(int vol_l, int vol_r) |
diff --git a/firmware/drivers/audio/uda1380.c b/firmware/drivers/audio/uda1380.c index e76b08a429..a0e7ef56d8 100644 --- a/firmware/drivers/audio/uda1380.c +++ b/firmware/drivers/audio/uda1380.c | |||
@@ -193,17 +193,6 @@ static int audiohw_set_regs(void) | |||
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
196 | /* Silently enable / disable audio output */ | ||
197 | void audiohw_enable_output(bool enable) | ||
198 | { | ||
199 | if (enable) { | ||
200 | uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_DAC | PON_HP); | ||
201 | } else { | ||
202 | uda1380_write_reg(REG_MUTE, MUTE_MASTER); | ||
203 | uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] & ~PON_DAC); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | static void reset(void) | 196 | static void reset(void) |
208 | { | 197 | { |
209 | #ifdef IRIVER_H300_SERIES | 198 | #ifdef IRIVER_H300_SERIES |
@@ -278,8 +267,9 @@ void audiohw_postinit(void) | |||
278 | /* Sleep a while so the power can stabilize (especially a long | 267 | /* Sleep a while so the power can stabilize (especially a long |
279 | delay is needed for the line out connector). */ | 268 | delay is needed for the line out connector). */ |
280 | sleep(HZ); | 269 | sleep(HZ); |
270 | |||
281 | /* Power on FSDAC and HP amp. */ | 271 | /* Power on FSDAC and HP amp. */ |
282 | audiohw_enable_output(true); | 272 | uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_DAC | PON_HP); |
283 | 273 | ||
284 | /* UDA1380: Unmute the master channel | 274 | /* UDA1380: Unmute the master channel |
285 | (DAC should be at zero point now). */ | 275 | (DAC should be at zero point now). */ |
diff --git a/firmware/drivers/audio/wm8721.c b/firmware/drivers/audio/wm8721.c index 6c4e12b9dc..3f14ca467e 100644 --- a/firmware/drivers/audio/wm8721.c +++ b/firmware/drivers/audio/wm8721.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include "wmcodec.h" | 34 | #include "wmcodec.h" |
35 | #include "audiohw.h" | 35 | #include "audiohw.h" |
36 | #include "i2s.h" | ||
37 | 36 | ||
38 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ | 37 | #define IPOD_PCM_LEVEL 0x65 /* -6dB */ |
39 | 38 | ||
@@ -91,43 +90,38 @@ static void codec_set_active(int active) | |||
91 | 90 | ||
92 | 91 | ||
93 | /* Silently enable / disable audio output */ | 92 | /* Silently enable / disable audio output */ |
94 | void audiohw_enable_output(bool enable) | 93 | void audiohw_preinit(void) |
95 | { | 94 | { |
96 | if (enable) | 95 | wmcodec_write(RESET, 0x0); /*Reset*/ |
97 | { | ||
98 | /* reset the I2S controller into known state */ | ||
99 | i2s_reset(); | ||
100 | |||
101 | wmcodec_write(RESET, 0x0); /*Reset*/ | ||
102 | 96 | ||
103 | codec_set_active(0x0); | 97 | codec_set_active(0x0); |
104 | 98 | ||
105 | /* DACSEL=1 */ | 99 | /* DACSEL=1 */ |
106 | wmcodec_write(0x4, 0x10); | 100 | wmcodec_write(0x4, 0x10); |
107 | 101 | ||
108 | /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */ | 102 | /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */ |
109 | wmcodec_write(PDCTRL, 0x67); | 103 | wmcodec_write(PDCTRL, 0x67); |
110 | 104 | ||
111 | /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ | 105 | /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ |
112 | /* IWL=00(16 bit) FORMAT=10(I2S format) */ | 106 | /* IWL=00(16 bit) FORMAT=10(I2S format) */ |
113 | wmcodec_write(AINTFCE, 0x42); | 107 | wmcodec_write(AINTFCE, 0x42); |
114 | 108 | ||
115 | audiohw_set_sample_rate(WM8721_USB24_44100HZ); | 109 | audiohw_set_sample_rate(WM8721_USB24_44100HZ); |
116 | 110 | ||
117 | /* set the volume to -6dB */ | 111 | /* set the volume to -6dB */ |
118 | wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL); | 112 | wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL); |
119 | wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL); | 113 | wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL); |
120 | 114 | ||
121 | /* ACTIVE=1 */ | 115 | /* ACTIVE=1 */ |
122 | codec_set_active(1); | 116 | codec_set_active(1); |
123 | 117 | ||
124 | /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */ | 118 | /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */ |
125 | wmcodec_write(DAPCTRL, 0x0); | 119 | wmcodec_write(DAPCTRL, 0x0); |
120 | } | ||
126 | 121 | ||
127 | audiohw_mute(0); | 122 | void audiohw_postinit(void) |
128 | } else { | 123 | { |
129 | audiohw_mute(1); | 124 | audiohw_mute(0); |
130 | } | ||
131 | } | 125 | } |
132 | 126 | ||
133 | void audiohw_set_master_vol(int vol_l, int vol_r) | 127 | void audiohw_set_master_vol(int vol_l, int vol_r) |
diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c index d6e21c34de..2f882e8fe1 100644 --- a/firmware/drivers/audio/wm8731.c +++ b/firmware/drivers/audio/wm8731.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include "wmcodec.h" | 34 | #include "wmcodec.h" |
35 | #include "audiohw.h" | 35 | #include "audiohw.h" |
36 | #include "i2s.h" | ||
37 | #include "sound.h" | 36 | #include "sound.h" |
38 | 37 | ||
39 | const struct sound_settings_info audiohw_settings[] = { | 38 | const struct sound_settings_info audiohw_settings[] = { |
@@ -150,8 +149,6 @@ static void codec_set_active(int active) | |||
150 | 149 | ||
151 | void audiohw_preinit(void) | 150 | void audiohw_preinit(void) |
152 | { | 151 | { |
153 | i2s_reset(); | ||
154 | |||
155 | /* POWER UP SEQUENCE */ | 152 | /* POWER UP SEQUENCE */ |
156 | /* 1) Switch on power supplies. By default the WM8731 is in Standby Mode, | 153 | /* 1) Switch on power supplies. By default the WM8731 is in Standby Mode, |
157 | * the DAC is digitally muted and the Audio Interface and Outputs are | 154 | * the DAC is digitally muted and the Audio Interface and Outputs are |
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c index 7145fe4ea4..d53cfa3d79 100644 --- a/firmware/drivers/audio/wm8751.c +++ b/firmware/drivers/audio/wm8751.c | |||
@@ -27,7 +27,6 @@ | |||
27 | ****************************************************************************/ | 27 | ****************************************************************************/ |
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "wmcodec.h" | 29 | #include "wmcodec.h" |
30 | #include "i2s.h" | ||
31 | #include "audio.h" | 30 | #include "audio.h" |
32 | #include "audiohw.h" | 31 | #include "audiohw.h" |
33 | #include "system.h" | 32 | #include "system.h" |
diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c index e9d4b5c5c7..8ebfbe8e26 100644 --- a/firmware/drivers/audio/wm8758.c +++ b/firmware/drivers/audio/wm8758.c | |||
@@ -31,7 +31,6 @@ | |||
31 | 31 | ||
32 | #include "wmcodec.h" | 32 | #include "wmcodec.h" |
33 | #include "audiohw.h" | 33 | #include "audiohw.h" |
34 | #include "i2s.h" | ||
35 | 34 | ||
36 | const struct sound_settings_info audiohw_settings[] = { | 35 | const struct sound_settings_info audiohw_settings[] = { |
37 | [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25}, | 36 | [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25}, |
@@ -95,8 +94,6 @@ void audiohw_mute(bool mute) | |||
95 | 94 | ||
96 | void audiohw_preinit(void) | 95 | void audiohw_preinit(void) |
97 | { | 96 | { |
98 | i2s_reset(); | ||
99 | |||
100 | wmcodec_write(RESET, RESET_RESET); | 97 | wmcodec_write(RESET, RESET_RESET); |
101 | 98 | ||
102 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN | 99 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN |
diff --git a/firmware/drivers/audio/wm8975.c b/firmware/drivers/audio/wm8975.c index 86e463cdff..aa519e8819 100644 --- a/firmware/drivers/audio/wm8975.c +++ b/firmware/drivers/audio/wm8975.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include "wmcodec.h" | 34 | #include "wmcodec.h" |
35 | #include "audiohw.h" | 35 | #include "audiohw.h" |
36 | #include "i2s.h" | ||
37 | 36 | ||
38 | const struct sound_settings_info audiohw_settings[] = { | 37 | const struct sound_settings_info audiohw_settings[] = { |
39 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | 38 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, |
@@ -129,8 +128,6 @@ void audiohw_mute(bool mute) | |||
129 | 128 | ||
130 | void audiohw_preinit(void) | 129 | void audiohw_preinit(void) |
131 | { | 130 | { |
132 | i2s_reset(); | ||
133 | |||
134 | /* POWER UP SEQUENCE */ | 131 | /* POWER UP SEQUENCE */ |
135 | wmcodec_write(RESET, RESET_RESET); | 132 | wmcodec_write(RESET, RESET_RESET); |
136 | 133 | ||
diff --git a/firmware/drivers/audio/wm8985.c b/firmware/drivers/audio/wm8985.c index 9d80f9e374..0467e3718a 100644 --- a/firmware/drivers/audio/wm8985.c +++ b/firmware/drivers/audio/wm8985.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include "wmcodec.h" | 24 | #include "wmcodec.h" |
25 | #include "audiohw.h" | 25 | #include "audiohw.h" |
26 | #include "i2s.h" | ||
27 | 26 | ||
28 | /* Register addresses as per datasheet Rev.4.4 */ | 27 | /* Register addresses as per datasheet Rev.4.4 */ |
29 | #define RESET 0x00 | 28 | #define RESET 0x00 |
@@ -127,57 +126,50 @@ int tenthdb2master(int db) | |||
127 | } | 126 | } |
128 | 127 | ||
129 | /* Silently enable / disable audio output */ | 128 | /* Silently enable / disable audio output */ |
130 | void audiohw_enable_output(bool enable) | 129 | void audiohw_preinit(void) |
131 | { | 130 | { |
132 | if (enable) | 131 | wmcodec_write(RESET, 0x1ff); /* Reset */ |
133 | { | ||
134 | /* TODO: reset the I2S controller into known state */ | ||
135 | //i2s_reset(); | ||
136 | 132 | ||
137 | wmcodec_write(RESET, 0x1ff); /* Reset */ | 133 | wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */ |
134 | wmcodec_write(OUTCTRL, 0x6); /* Thermal shutdown */ | ||
138 | 135 | ||
139 | wmcodec_write(BIASCTL, 0x100); /* BIASCUT = 1 */ | 136 | wmcodec_write(PWRMGMT1, 0x8); /* BIASEN = 1 */ |
140 | wmcodec_write(OUTCTRL, 0x6); /* Thermal shutdown */ | ||
141 | 137 | ||
142 | wmcodec_write(PWRMGMT1, 0x8); /* BIASEN = 1 */ | 138 | /* Volume zero, mute all outputs */ |
139 | wmcodec_write(LOUT1VOL, 0x140); | ||
140 | wmcodec_write(ROUT1VOL, 0x140); | ||
141 | wmcodec_write(LOUT2VOL, 0x140); | ||
142 | wmcodec_write(ROUT2VOL, 0x140); | ||
143 | wmcodec_write(OUT3MIX, 0x40); | ||
144 | wmcodec_write(OUT4MIX, 0x40); | ||
143 | 145 | ||
144 | /* Volume zero, mute all outputs */ | 146 | /* DAC softmute, automute, 128OSR */ |
145 | wmcodec_write(LOUT1VOL, 0x140); | 147 | wmcodec_write(DACCTRL, 0x4c); |
146 | wmcodec_write(ROUT1VOL, 0x140); | ||
147 | wmcodec_write(LOUT2VOL, 0x140); | ||
148 | wmcodec_write(ROUT2VOL, 0x140); | ||
149 | wmcodec_write(OUT3MIX, 0x40); | ||
150 | wmcodec_write(OUT4MIX, 0x40); | ||
151 | |||
152 | /* DAC softmute, automute, 128OSR */ | ||
153 | wmcodec_write(DACCTRL, 0x4c); | ||
154 | 148 | ||
155 | wmcodec_write(OUT4ADC, 0x2); /* POBCTRL = 1 */ | 149 | wmcodec_write(OUT4ADC, 0x2); /* POBCTRL = 1 */ |
156 | 150 | ||
157 | /* Enable output, DAC and mixer */ | 151 | /* Enable output, DAC and mixer */ |
158 | wmcodec_write(PWRMGMT3, 0x6f); | 152 | wmcodec_write(PWRMGMT3, 0x6f); |
159 | wmcodec_write(PWRMGMT2, 0x180); | 153 | wmcodec_write(PWRMGMT2, 0x180); |
160 | wmcodec_write(PWRMGMT1, 0xd); | 154 | wmcodec_write(PWRMGMT1, 0xd); |
161 | wmcodec_write(LOUTMIX, 0x1); | 155 | wmcodec_write(LOUTMIX, 0x1); |
162 | wmcodec_write(ROUTMIX, 0x1); | 156 | wmcodec_write(ROUTMIX, 0x1); |
163 | 157 | ||
164 | /* Disable clock since we're acting as slave to the SoC */ | 158 | /* Disable clock since we're acting as slave to the SoC */ |
165 | wmcodec_write(CLKGEN, 0x0); | 159 | wmcodec_write(CLKGEN, 0x0); |
166 | wmcodec_write(AINTFCE, 0x10); /* 16-bit, I2S format */ | 160 | wmcodec_write(AINTFCE, 0x10); /* 16-bit, I2S format */ |
167 | 161 | ||
168 | wmcodec_write(LDACVOL, 0x1ff); /* Full DAC digital vol */ | 162 | wmcodec_write(LDACVOL, 0x1ff); /* Full DAC digital vol */ |
169 | wmcodec_write(RDACVOL, 0x1ff); | 163 | wmcodec_write(RDACVOL, 0x1ff); |
170 | 164 | ||
171 | wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */ | 165 | wmcodec_write(OUT4ADC, 0x0); /* POBCTRL = 0 */ |
166 | } | ||
172 | 167 | ||
173 | sleep(HZ/2); | 168 | void audiohw_postinit(void) |
169 | { | ||
170 | sleep(HZ/2); | ||
174 | 171 | ||
175 | audiohw_mute(0); | 172 | audiohw_mute(0); |
176 | } | ||
177 | else | ||
178 | { | ||
179 | audiohw_mute(1); | ||
180 | } | ||
181 | } | 173 | } |
182 | 174 | ||
183 | void audiohw_set_headphone_vol(int vol_l, int vol_r) | 175 | void audiohw_set_headphone_vol(int vol_l, int vol_r) |
@@ -256,9 +248,6 @@ void audiohw_enable_recording(bool source_mic) | |||
256 | { | 248 | { |
257 | (void)source_mic; /* We only have a line-in (I think) */ | 249 | (void)source_mic; /* We only have a line-in (I think) */ |
258 | 250 | ||
259 | /* TODO: reset the I2S controller into known state */ | ||
260 | //i2s_reset(); | ||
261 | |||
262 | wmcodec_write(RESET, 0x1ff); /*Reset*/ | 251 | wmcodec_write(RESET, 0x1ff); /*Reset*/ |
263 | 252 | ||
264 | wmcodec_write(PWRMGMT1, 0x2b); | 253 | wmcodec_write(PWRMGMT1, 0x2b); |