diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/audio/ak4537.c | 114 | ||||
-rw-r--r-- | firmware/drivers/tuner/tea5767.c | 31 |
2 files changed, 105 insertions, 40 deletions
diff --git a/firmware/drivers/audio/ak4537.c b/firmware/drivers/audio/ak4537.c index bea3dc7019..a42b1346d2 100644 --- a/firmware/drivers/audio/ak4537.c +++ b/firmware/drivers/audio/ak4537.c | |||
@@ -221,34 +221,64 @@ void audiohw_set_frequency(int fsel) | |||
221 | } | 221 | } |
222 | 222 | ||
223 | #if defined(HAVE_RECORDING) | 223 | #if defined(HAVE_RECORDING) |
224 | void audiohw_enable_recording(bool source_mic) | 224 | void audiohw_set_recsrc(int source) |
225 | { | 225 | { |
226 | if (source_mic) | 226 | switch(source) |
227 | { | 227 | { |
228 | /* enable mic power supply */ | 228 | case AUDIO_SRC_PLAYBACK: |
229 | /* disable mic power supply */ | ||
229 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) | 230 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) |
230 | /* additionally select external mic */ | 231 | akc_clear(AK4537_MIC, MPWRE); |
231 | akc_set(AK4537_MIC, MPWRE | MSEL); | ||
232 | #else | 232 | #else |
233 | akc_set(AK4537_MIC, MPWRI); | 233 | akc_clear(AK4537_MIC, MPWRI); |
234 | #endif | 234 | #endif |
235 | /* power down ADC, mic preamp and line amp */ | ||
236 | akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL); | ||
237 | akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR); | ||
235 | 238 | ||
236 | /* mic out is connected to line1 input */ | 239 | /* break ADC -> DAC connection */ |
237 | akc_clear(AK4537_PM3, INL | INR); | 240 | akc_clear(AK4537_MODE2, LOOP); |
241 | |||
242 | break; | ||
243 | |||
244 | #if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO) | ||
245 | case AUDIO_SRC_FMRADIO: | ||
246 | /* disable mic power supply */ | ||
247 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) | ||
248 | akc_clear(AK4537_MIC, MPWRE); | ||
249 | #else | ||
250 | akc_clear(AK4537_MIC, MPWRI); | ||
251 | #endif | ||
252 | /* disable mic preamp */ | ||
253 | akc_clear(AK4537_PM1, PMMICL); | ||
238 | 254 | ||
255 | /* Select line2 input: Radio */ | ||
256 | akc_set(AK4537_PM3, INL | INR); | ||
239 | /* route ALC output to ADC input */ | 257 | /* route ALC output to ADC input */ |
240 | akc_set(AK4537_MIC, MICAD); | 258 | akc_set(AK4537_MIC, MICAD); |
241 | /* set ALC (automatic level control) to manual mode */ | 259 | /* set ALC (automatic level control) to manual mode */ |
242 | akc_clear(AK4537_ALC1, ALC1); | 260 | akc_clear(AK4537_ALC1, ALC1); |
243 | /* set gain control to 'dependent' (left&right at the same time) */ | 261 | |
244 | akc_clear(AK4537_MIC, IPGAC); | 262 | /* set gain control to independent left & right gain */ |
245 | /* power up mic preamp, left channel ADC and line in */ | 263 | akc_set(AK4537_MIC, IPGAC); |
246 | akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL); | 264 | |
247 | /* power up right channel ADC and line in */ | 265 | /* power up left channel input and ADC */ |
266 | akc_set(AK4537_PM1, PMADL | PMIPGL); | ||
267 | /* power up right channel input and ADC */ | ||
248 | akc_set(AK4537_PM3, PMADR | PMIPGR); | 268 | akc_set(AK4537_PM3, PMADR | PMIPGR); |
249 | } | 269 | |
250 | else | 270 | /* set line in vol = 0 dB */ |
251 | { | 271 | akc_write(AK4537_IPGAL, 0x2f); |
272 | akc_write(AK4537_IPGAR, 0x2f); | ||
273 | |||
274 | /* ADC -> DAC, external data to DAC ignored */ | ||
275 | akc_set(AK4537_MODE2, LOOP); | ||
276 | |||
277 | break; | ||
278 | #endif /* INPUT_SRC_CAPS & SRC_CAP_FMRADIO */ | ||
279 | |||
280 | #if (INPUT_SRC_CAPS & SRC_CAP_LINEIN) | ||
281 | case AUDIO_SRC_LINEIN: | ||
252 | /* disable mic power supply */ | 282 | /* disable mic power supply */ |
253 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) | 283 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) |
254 | akc_clear(AK4537_MIC, MPWRE); | 284 | akc_clear(AK4537_MIC, MPWRE); |
@@ -272,25 +302,44 @@ void audiohw_enable_recording(bool source_mic) | |||
272 | akc_set(AK4537_PM1, PMADL | PMIPGL); | 302 | akc_set(AK4537_PM1, PMADL | PMIPGL); |
273 | /* power up right channel input and ADC */ | 303 | /* power up right channel input and ADC */ |
274 | akc_set(AK4537_PM3, PMADR | PMIPGR); | 304 | akc_set(AK4537_PM3, PMADR | PMIPGR); |
275 | } | ||
276 | /* ADC -> DAC, external data to DAC ignored */ | ||
277 | akc_set(AK4537_MODE2, LOOP); | ||
278 | } | ||
279 | 305 | ||
280 | void audiohw_disable_recording(void) | 306 | /* ADC -> DAC, external data to DAC ignored */ |
281 | { | 307 | akc_set(AK4537_MODE2, LOOP); |
282 | /* disable mic power supply */ | 308 | |
309 | break; | ||
310 | #endif /* INPUT_SRC_CAPS & SRC_CAP_LINEIN */ | ||
311 | |||
312 | #if (INPUT_SRC_CAPS & SRC_CAP_MIC) | ||
313 | case AUDIO_SRC_MIC: | ||
314 | /* enable mic power supply */ | ||
283 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) | 315 | #if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) |
284 | akc_clear(AK4537_MIC, MPWRE); | 316 | /* additionally select external mic */ |
317 | akc_set(AK4537_MIC, MPWRE | MSEL); | ||
285 | #else | 318 | #else |
286 | akc_clear(AK4537_MIC, MPWRI); | 319 | akc_set(AK4537_MIC, MPWRI); |
287 | #endif | 320 | #endif |
288 | /* power down ADC, mic preamp and line amp */ | ||
289 | akc_clear(AK4537_PM1, PMADL | PMMICL | PMIPGL); | ||
290 | akc_clear(AK4537_PM3, PMADR | PMMICR | PMIPGR); | ||
291 | 321 | ||
292 | /* break ADC -> DAC connection */ | 322 | /* mic out is connected to line1 input */ |
293 | akc_clear(AK4537_MODE2, LOOP); | 323 | akc_clear(AK4537_PM3, INL | INR); |
324 | |||
325 | /* route ALC output to ADC input */ | ||
326 | akc_set(AK4537_MIC, MICAD); | ||
327 | /* set ALC (automatic level control) to manual mode */ | ||
328 | akc_clear(AK4537_ALC1, ALC1); | ||
329 | /* set gain control to 'dependent' (left&right at the same time) */ | ||
330 | akc_clear(AK4537_MIC, IPGAC); | ||
331 | /* power up mic preamp, left channel ADC and line in */ | ||
332 | akc_set(AK4537_PM1, PMMICL | PMIPGL | PMADL); | ||
333 | /* power up right channel ADC and line in */ | ||
334 | akc_set(AK4537_PM3, PMADR | PMIPGR); | ||
335 | |||
336 | /* ADC -> DAC, external data to DAC ignored */ | ||
337 | akc_set(AK4537_MODE2, LOOP); | ||
338 | |||
339 | break; | ||
340 | #endif /* INPUT_SRC_CAPS & SRC_CAP_MIC) */ | ||
341 | |||
342 | } /* switch(source) */ | ||
294 | } | 343 | } |
295 | 344 | ||
296 | void audiohw_set_recvol(int left, int right, int type) | 345 | void audiohw_set_recvol(int left, int right, int type) |
@@ -331,9 +380,4 @@ void audiohw_set_recvol(int left, int right, int type) | |||
331 | return; | 380 | return; |
332 | } | 381 | } |
333 | } | 382 | } |
334 | |||
335 | void audiohw_set_monitor(bool enable) | ||
336 | { | ||
337 | (void)enable; | ||
338 | } | ||
339 | #endif /* HAVE_RECORDING */ | 383 | #endif /* HAVE_RECORDING */ |
diff --git a/firmware/drivers/tuner/tea5767.c b/firmware/drivers/tuner/tea5767.c index d0041f9ce1..74adb54997 100644 --- a/firmware/drivers/tuner/tea5767.c +++ b/firmware/drivers/tuner/tea5767.c | |||
@@ -27,7 +27,9 @@ | |||
27 | #include "power.h" | 27 | #include "power.h" |
28 | #include "tuner.h" /* tuner abstraction interface */ | 28 | #include "tuner.h" /* tuner abstraction interface */ |
29 | #include "fmradio.h" | 29 | #include "fmradio.h" |
30 | #include "fmradio_i2c.h" /* physical interface driver */ | 30 | #include "fmradio_i2c.h" /* physical interface driver - i2c */ |
31 | #include "fmradio_3wire.h" /* physical interface driver - 3-wire bus */ | ||
32 | |||
31 | 33 | ||
32 | #if defined(PHILIPS_HDD1630) || defined(ONDA_VX747) || defined(ONDA_VX777) || defined(PHILIPS_HDD6330) | 34 | #if defined(PHILIPS_HDD1630) || defined(ONDA_VX747) || defined(ONDA_VX777) || defined(PHILIPS_HDD6330) |
33 | #define I2C_ADR 0x60 | 35 | #define I2C_ADR 0x60 |
@@ -109,7 +111,11 @@ int tea5767_set(int setting, int value) | |||
109 | 111 | ||
110 | if(setting == RADIO_SLEEP && !value) | 112 | if(setting == RADIO_SLEEP && !value) |
111 | tuner_power(true); /* wakeup */ | 113 | tuner_power(true); /* wakeup */ |
114 | #if defined(CONFIG_TUNER_3WIRE) | ||
115 | fmradio_3wire_write(write_bytes); | ||
116 | #else | ||
112 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | 117 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); |
118 | #endif | ||
113 | if(setting == RADIO_SLEEP && value) | 119 | if(setting == RADIO_SLEEP && value) |
114 | tuner_power(false); /* sleep */ | 120 | tuner_power(false); /* sleep */ |
115 | return 1; | 121 | return 1; |
@@ -121,7 +127,11 @@ int tea5767_get(int setting) | |||
121 | unsigned char read_bytes[5]; | 127 | unsigned char read_bytes[5]; |
122 | int val = -1; /* default for unsupported query */ | 128 | int val = -1; /* default for unsupported query */ |
123 | 129 | ||
130 | #if defined(CONFIG_TUNER_3WIRE) | ||
131 | fmradio_3wire_read(read_bytes); | ||
132 | #else | ||
124 | fmradio_i2c_read(I2C_ADR, read_bytes, sizeof(read_bytes)); | 133 | fmradio_i2c_read(I2C_ADR, read_bytes, sizeof(read_bytes)); |
134 | #endif | ||
125 | 135 | ||
126 | switch(setting) | 136 | switch(setting) |
127 | { | 137 | { |
@@ -141,7 +151,7 @@ int tea5767_get(int setting) | |||
141 | case RADIO_STEREO: | 151 | case RADIO_STEREO: |
142 | val = read_bytes[2] >> 7; | 152 | val = read_bytes[2] >> 7; |
143 | break; | 153 | break; |
144 | 154 | ||
145 | case RADIO_RSSI: | 155 | case RADIO_RSSI: |
146 | val = 10 + 3*(read_bytes[3] >> 4); | 156 | val = 10 + 3*(read_bytes[3] >> 4); |
147 | break; | 157 | break; |
@@ -161,15 +171,22 @@ int tea5767_get(int setting) | |||
161 | void tea5767_init(void) | 171 | void tea5767_init(void) |
162 | { | 172 | { |
163 | /* save binsize by only detecting presence for targets where it may be absent */ | 173 | /* save binsize by only detecting presence for targets where it may be absent */ |
164 | #if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) | 174 | #if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) || defined(SAMSUNG_YH920) |
165 | unsigned char buf[5]; | 175 | unsigned char buf[5]; |
166 | unsigned char chipid; | 176 | unsigned char chipid; |
167 | 177 | ||
168 | /* init chipid register with 0xFF in case fmradio_i2c_read fails silently */ | 178 | /* init chipid register with 0xFF in case fmradio_i2c_read fails silently */ |
169 | buf[3] = 0xFF; | 179 | buf[3] = 0xFF; |
170 | tuner_power(true); | 180 | tuner_power(true); |
171 | if (fmradio_i2c_read(I2C_ADR, buf, sizeof(buf)) < 0) { | 181 | |
172 | /* no i2c device detected */ | 182 | #if defined(CONFIG_TUNER_3WIRE) |
183 | int res = fmradio_3wire_read(buf); | ||
184 | #else | ||
185 | int res = fmradio_i2c_read(I2C_ADR, buf, sizeof(buf)); | ||
186 | #endif | ||
187 | |||
188 | if (res < 0) { | ||
189 | /* no device detected on bus */ | ||
173 | tuner_present = false; | 190 | tuner_present = false; |
174 | } else { | 191 | } else { |
175 | /* check chip id */ | 192 | /* check chip id */ |
@@ -182,6 +199,10 @@ void tea5767_init(void) | |||
182 | 199 | ||
183 | void tea5767_dbg_info(struct tea5767_dbg_info *info) | 200 | void tea5767_dbg_info(struct tea5767_dbg_info *info) |
184 | { | 201 | { |
202 | #if defined(CONFIG_TUNER_3WIRE) | ||
203 | fmradio_3wire_read(info->read_regs); | ||
204 | #else | ||
185 | fmradio_i2c_read(I2C_ADR, info->read_regs, 5); | 205 | fmradio_i2c_read(I2C_ADR, info->read_regs, 5); |
206 | #endif | ||
186 | memcpy(info->write_regs, write_bytes, 5); | 207 | memcpy(info->write_regs, write_bytes, 5); |
187 | } | 208 | } |