diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-04-14 00:49:35 +0000 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-04-14 00:49:35 +0000 |
commit | ca6f4abcf17a84d52646a8a6b305ab1011efe6d0 (patch) | |
tree | 5c349f157024d96f38ede356bcd39bf9796154cd /firmware/drivers/as3514.c | |
parent | 17c93f9be0e2a322d8f42410f98629fb5e161742 (diff) | |
download | rockbox-ca6f4abcf17a84d52646a8a6b305ab1011efe6d0.tar.gz rockbox-ca6f4abcf17a84d52646a8a6b305ab1011efe6d0.zip |
* make it louder - inspired by FS #6911
* disable some unneeded stuff -> save power
* remove some unneeded functions
* shadow registers, so we dont need to do so much i2c traffic
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13150 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/as3514.c')
-rw-r--r-- | firmware/drivers/as3514.c | 110 |
1 files changed, 63 insertions, 47 deletions
diff --git a/firmware/drivers/as3514.c b/firmware/drivers/as3514.c index f7eb0bd0ec..672087dbd0 100644 --- a/firmware/drivers/as3514.c +++ b/firmware/drivers/as3514.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * Driver for AS3514 audio codec | 10 | * Driver for AS3514 audio codec |
11 | * | 11 | * |
12 | * Copyright (c) 2007 Daniel Ankers | 12 | * Copyright (c) 2007 Daniel Ankers |
13 | * Copyright (c) 2007 Christian Gmeiner | ||
13 | * | 14 | * |
14 | * All files in this archive are subject to the GNU General Public License. | 15 | * All files in this archive are subject to the GNU General Public License. |
15 | * See the file COPYING in the source tree root for full license agreement. | 16 | * See the file COPYING in the source tree root for full license agreement. |
@@ -32,11 +33,29 @@ | |||
32 | #include "buffer.h" | 33 | #include "buffer.h" |
33 | #include "audio.h" | 34 | #include "audio.h" |
34 | #include "backlight.h" | 35 | #include "backlight.h" |
36 | #include "logf.h" | ||
35 | 37 | ||
36 | #include "as3514.h" | 38 | #include "as3514.h" |
37 | #include "i2s.h" | 39 | #include "i2s.h" |
38 | #include "i2c-pp.h" | 40 | #include "i2c-pp.h" |
39 | 41 | ||
42 | /* Shadow registers */ | ||
43 | int as3514_regs[0x1D]; | ||
44 | |||
45 | /* | ||
46 | * little helper method to set register values. | ||
47 | * With the help of as3514_regs, we minimize i2c | ||
48 | * traffic. | ||
49 | */ | ||
50 | static void as3514_write(int reg, int value) | ||
51 | { | ||
52 | if (pp_i2c_send(AS3514_I2C_ADDR, reg, value) != 2) | ||
53 | { | ||
54 | DEBUGF("as3514 error reg=0x%x", reg); | ||
55 | } | ||
56 | as3514_regs[reg] = value; | ||
57 | } | ||
58 | |||
40 | /* convert tenth of dB volume to master volume register value */ | 59 | /* convert tenth of dB volume to master volume register value */ |
41 | int tenthdb2master(int db) | 60 | int tenthdb2master(int db) |
42 | { | 61 | { |
@@ -73,7 +92,10 @@ void audiohw_reset(void); | |||
73 | /* | 92 | /* |
74 | * Initialise the PP I2C and I2S. | 93 | * Initialise the PP I2C and I2S. |
75 | */ | 94 | */ |
76 | int audiohw_init(void) { | 95 | int audiohw_init(void) |
96 | { | ||
97 | unsigned int i; | ||
98 | |||
77 | /* reset I2C */ | 99 | /* reset I2C */ |
78 | i2c_init(); | 100 | i2c_init(); |
79 | 101 | ||
@@ -100,11 +122,18 @@ int audiohw_init(void) { | |||
100 | i2s_reset(); | 122 | i2s_reset(); |
101 | 123 | ||
102 | /* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */ | 124 | /* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */ |
103 | pp_i2c_send(AS3514_I2C_ADDR, AUDIOSET1, 0x60); /* Turn on DAC and mixer */ | 125 | as3514_write(AUDIOSET1, 0x60); /* Turn on DAC and mixer */ |
104 | pp_i2c_send(AS3514_I2C_ADDR, PLLMODE, 0x04); | 126 | as3514_write(AUDIOSET3, 0x5); /* Set HPCM off, ZCU off*/ |
105 | pp_i2c_send(AS3514_I2C_ADDR, DAC_L, 0x50); /* DAC mute off, -16.5dB gain */ | 127 | as3514_write(HPH_OUT_R, 0xc0 | 0x16); /* set vol and set speaker over-current to 0 */ |
106 | pp_i2c_send(AS3514_I2C_ADDR, DAC_R, 0x10); /* DAC -16.5dB gain to prevent overloading | 128 | as3514_write(HPH_OUT_L, 0x40 | 0x16); /* set default vol for headphone */ |
107 | the headphone amp */ | 129 | as3514_write(PLLMODE, 0x04); |
130 | |||
131 | /* read all reg values */ | ||
132 | for (i = 0; i < sizeof(as3514_regs); i++) | ||
133 | { | ||
134 | as3514_regs[i] = i2c_readbyte(AS3514_I2C_ADDR, i); | ||
135 | } | ||
136 | |||
108 | return 0; | 137 | return 0; |
109 | } | 138 | } |
110 | 139 | ||
@@ -120,11 +149,11 @@ void audiohw_enable_output(bool enable) | |||
120 | /* reset the I2S controller into known state */ | 149 | /* reset the I2S controller into known state */ |
121 | i2s_reset(); | 150 | i2s_reset(); |
122 | 151 | ||
123 | pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, 0xc0); /* Mute on, power on */ | 152 | as3514_write(HPH_OUT_L, 0xc0); /* Mute off, power on */ |
124 | audiohw_mute(0); | 153 | audiohw_mute(0); |
125 | } else { | 154 | } else { |
126 | audiohw_mute(1); | 155 | audiohw_mute(1); |
127 | pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, 0x80); /* Mute on, power off */ | 156 | as3514_write(HPH_OUT_L, 0x80); /* Mute on, power off */ |
128 | } | 157 | } |
129 | } | 158 | } |
130 | 159 | ||
@@ -132,16 +161,22 @@ int audiohw_set_master_vol(int vol_l, int vol_r) | |||
132 | { | 161 | { |
133 | vol_l &= 0x1f; | 162 | vol_l &= 0x1f; |
134 | vol_r &= 0x1f; | 163 | vol_r &= 0x1f; |
135 | pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_R, vol_r); | 164 | |
136 | pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, 0x40 | vol_l); | 165 | /* we are controling dac volume instead of headphone volume, |
166 | as the volume is bigger. | ||
167 | HDP: 1.07 dB gain | ||
168 | DAC: 6 dB gain | ||
169 | */ | ||
170 | as3514_write(DAC_R, vol_r); | ||
171 | as3514_write(DAC_L, 0x40 | vol_l); | ||
137 | 172 | ||
138 | return 0; | 173 | return 0; |
139 | } | 174 | } |
140 | 175 | ||
141 | int audiohw_set_lineout_vol(int vol_l, int vol_r) | 176 | int audiohw_set_lineout_vol(int vol_l, int vol_r) |
142 | { | 177 | { |
143 | pp_i2c_send(AS3514_I2C_ADDR, LINE_OUT_R, vol_r); | 178 | as3514_write(LINE_OUT_R, vol_r); |
144 | pp_i2c_send(AS3514_I2C_ADDR, LINE_OUT_L, 0x40 | vol_l); | 179 | as3514_write(LINE_OUT_L, 0x40 | vol_l); |
145 | 180 | ||
146 | return 0; | 181 | return 0; |
147 | } | 182 | } |
@@ -154,27 +189,16 @@ int audiohw_set_mixer_vol(int channel1, int channel2) | |||
154 | return 0; | 189 | return 0; |
155 | } | 190 | } |
156 | 191 | ||
157 | /* We are using Linear bass control */ | ||
158 | void audiohw_set_bass(int value) | ||
159 | { | ||
160 | (void)value; | ||
161 | } | ||
162 | |||
163 | void audiohw_set_treble(int value) | ||
164 | { | ||
165 | (void)value; | ||
166 | } | ||
167 | |||
168 | int audiohw_mute(int mute) | 192 | int audiohw_mute(int mute) |
169 | { | 193 | { |
170 | int curr; | 194 | int curr; |
171 | 195 | ||
172 | curr = i2c_readbyte(AS3514_I2C_ADDR, HPH_OUT_L); | 196 | curr = as3514_regs[HPH_OUT_L]; |
173 | if (mute) | 197 | if (mute) |
174 | { | 198 | { |
175 | pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, curr | 0x80); | 199 | as3514_write(HPH_OUT_L, curr | 0x80); |
176 | } else { | 200 | } else { |
177 | pp_i2c_send(AS3514_I2C_ADDR, HPH_OUT_L, curr & ~(0x80)); | 201 | as3514_write(HPH_OUT_L, curr & ~(0x80)); |
178 | } | 202 | } |
179 | 203 | ||
180 | return 0; | 204 | return 0; |
@@ -183,47 +207,39 @@ int audiohw_mute(int mute) | |||
183 | /* Nice shutdown of WM8758 codec */ | 207 | /* Nice shutdown of WM8758 codec */ |
184 | void audiohw_close(void) | 208 | void audiohw_close(void) |
185 | { | 209 | { |
210 | /* mute headphones */ | ||
186 | audiohw_mute(1); | 211 | audiohw_mute(1); |
187 | } | ||
188 | 212 | ||
189 | /* Change the order of the noise shaper, 5th order is recommended above 32kHz */ | 213 | /* mute mixer */ |
190 | void audiohw_set_nsorder(int order) | 214 | as3514_write(AUDIOSET1, 0x0); |
191 | { | 215 | |
192 | (void)order; | 216 | /* turn off everything */ |
217 | as3514_write(AUDIOSET1, 0x0); | ||
193 | } | 218 | } |
194 | 219 | ||
195 | void audiohw_set_sample_rate(int sampling_control) | 220 | void audiohw_set_sample_rate(int sampling_control) |
196 | { | 221 | { |
197 | (void)sampling_control; | 222 | (void)sampling_control; |
198 | /* TODO: Implement this by adjusting the I2S Master clock */ | ||
199 | } | 223 | } |
200 | 224 | ||
201 | void audiohw_enable_recording(bool source_mic) | 225 | void audiohw_enable_recording(bool source_mic) |
202 | { | 226 | { |
203 | (void)source_mic; | 227 | (void)source_mic; |
204 | /* TODO */ | ||
205 | } | 228 | } |
206 | 229 | ||
207 | void audiohw_disable_recording(void) { | 230 | void audiohw_disable_recording(void) |
208 | /* TODO */ | 231 | { |
232 | int curr; | ||
209 | } | 233 | } |
210 | 234 | ||
211 | void audiohw_set_recvol(int left, int right, int type) { | 235 | void audiohw_set_recvol(int left, int right, int type) |
212 | 236 | { | |
213 | (void)left; | 237 | (void)left; |
214 | (void)right; | 238 | (void)right; |
215 | (void)type; | 239 | (void)type; |
216 | } | 240 | } |
217 | 241 | ||
218 | void audiohw_set_monitor(int enable) { | 242 | void audiohw_set_monitor(int enable) |
219 | |||
220 | (void)enable; | ||
221 | } | ||
222 | |||
223 | void audiohw_set_equalizer_band(int band, int freq, int bw, int gain) | ||
224 | { | 243 | { |
225 | (void)band; | 244 | (void)enable; |
226 | (void)freq; | ||
227 | (void)bw; | ||
228 | (void)gain; | ||
229 | } | 245 | } |