summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Dziok <b0hoon@o2.pl>2014-06-17 23:13:15 +0000
committerSzymon Dziok <b0hoon@o2.pl>2014-06-18 18:06:17 +0000
commiteacd76cb80db12adcce74980e69d116911a8cde7 (patch)
tree239344e3f9053a75eeab4253f39f6b1dae749aa6
parent0c3dca1f33596cb10345601de32d681ed6ece972 (diff)
downloadrockbox-eacd76cb80db12adcce74980e69d116911a8cde7.tar.gz
rockbox-eacd76cb80db12adcce74980e69d116911a8cde7.zip
Radio and radio recording for Samsung YH-920.
There is no simple method to detect radio through the 3-wire interface, so it's not implemented for the YH-925 for now. YH-920 always has a radio. Change-Id: Iea484d752915fcd40dbbbd7dbbf13e81aaf548db
-rw-r--r--apps/keymaps/keymap-yh8xx_yh9xx.c27
-rw-r--r--apps/radio/radio.c3
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/drivers/audio/ak4537.c114
-rw-r--r--firmware/drivers/tuner/tea5767.c31
-rw-r--r--firmware/export/ak4537.h2
-rw-r--r--firmware/export/config/samsungyh920.h8
-rw-r--r--firmware/export/fmradio_3wire.h33
-rw-r--r--firmware/target/arm/pp/audio-pp.c21
-rw-r--r--firmware/target/arm/samsung/fmradio-yh92x.c120
-rw-r--r--firmware/target/arm/samsung/power-yh82x_yh92x.c19
11 files changed, 335 insertions, 44 deletions
diff --git a/apps/keymaps/keymap-yh8xx_yh9xx.c b/apps/keymaps/keymap-yh8xx_yh9xx.c
index 7125134d8c..03f6f8bcff 100644
--- a/apps/keymaps/keymap-yh8xx_yh9xx.c
+++ b/apps/keymaps/keymap-yh8xx_yh9xx.c
@@ -296,6 +296,27 @@ static const struct button_mapping button_context_keyboard[] = {
296 LAST_ITEM_IN_LIST 296 LAST_ITEM_IN_LIST
297}; /* button_context_keyboard */ 297}; /* button_context_keyboard */
298 298
299#if CONFIG_TUNER
300static const struct button_mapping button_context_radio[] = {
301 { ACTION_FM_MENU, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
302 { ACTION_FM_EXIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
303 { ACTION_FM_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
304 { ACTION_FM_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
305 { ACTION_FM_PRESET, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT},
306 { ACTION_FM_MODE, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
307 { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE },
308 { ACTION_SETTINGS_INCREPEAT,BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
309 { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE },
310 { ACTION_SETTINGS_DECREPEAT,BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
311 { ACTION_STD_NEXT, BUTTON_FFWD, BUTTON_NONE },
312 { ACTION_STD_NEXTREPEAT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE },
313 { ACTION_STD_PREV, BUTTON_REW, BUTTON_NONE },
314 { ACTION_STD_PREVREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
315
316 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
317}; /* button_context_radio */
318#endif
319
299const struct button_mapping* get_context_mapping(int context) 320const struct button_mapping* get_context_mapping(int context)
300{ 321{
301 switch (context) 322 switch (context)
@@ -342,6 +363,10 @@ const struct button_mapping* get_context_mapping(int context)
342 return button_context_recscreen; 363 return button_context_recscreen;
343 case CONTEXT_KEYBOARD: 364 case CONTEXT_KEYBOARD:
344 return button_context_keyboard; 365 return button_context_keyboard;
345 } 366#if CONFIG_TUNER
367 case CONTEXT_FM:
368 return button_context_radio;
369#endif
370 }
346 return button_context_standard; 371 return button_context_standard;
347} 372}
diff --git a/apps/radio/radio.c b/apps/radio/radio.c
index fdbcc89641..0365b6aafa 100644
--- a/apps/radio/radio.c
+++ b/apps/radio/radio.c
@@ -91,7 +91,8 @@
91#define FM_RECORD 91#define FM_RECORD
92 92
93#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || (CONFIG_KEYPAD == SANSA_C200_PAD) ||\ 93#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || (CONFIG_KEYPAD == SANSA_C200_PAD) ||\
94 (CONFIG_KEYPAD == SANSA_FUZE_PAD) || (CONFIG_KEYPAD == SANSA_CLIP_PAD) 94 (CONFIG_KEYPAD == SANSA_FUZE_PAD) || (CONFIG_KEYPAD == SANSA_CLIP_PAD) ||\
95 (CONFIG_KEYPAD == SAMSUNG_YH920_PAD)
95#define FM_MENU 96#define FM_MENU
96#define FM_PRESET 97#define FM_PRESET
97#define FM_STOP 98#define FM_STOP
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 374210e30b..ef71a2b048 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1705,6 +1705,7 @@ target/arm/samsung/yh920/backlight-yh920.c
1705target/arm/samsung/yh920/lcd-yh920.c 1705target/arm/samsung/yh920/lcd-yh920.c
1706target/arm/samsung/yh920/lcd-as-yh920.S 1706target/arm/samsung/yh920/lcd-as-yh920.S
1707target/arm/samsung/yh920/powermgmt-yh920.c 1707target/arm/samsung/yh920/powermgmt-yh920.c
1708target/arm/samsung/fmradio-yh92x.c
1708#endif /* SAMSUNG_YH920 */ 1709#endif /* SAMSUNG_YH920 */
1709 1710
1710#ifdef SAMSUNG_YH925 1711#ifdef SAMSUNG_YH925
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)
224void audiohw_enable_recording(bool source_mic) 224void 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
280void 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
296void audiohw_set_recvol(int left, int right, int type) 345void 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
335void 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)
161void tea5767_init(void) 171void 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
183void tea5767_dbg_info(struct tea5767_dbg_info *info) 200void 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}
diff --git a/firmware/export/ak4537.h b/firmware/export/ak4537.h
index 1c09b5aa2f..0ab0ca1594 100644
--- a/firmware/export/ak4537.h
+++ b/firmware/export/ak4537.h
@@ -34,6 +34,8 @@ AUDIOHW_SETTING(RIGHT_GAIN, "dB", 0, 1, -23, 12, 0)
34/* mic gain: +15dB fixed +20dB switchable mic preamp gain 34/* mic gain: +15dB fixed +20dB switchable mic preamp gain
35 and the line stage of -23..+12dB make a total range of -8..+47dB */ 35 and the line stage of -23..+12dB make a total range of -8..+47dB */
36AUDIOHW_SETTING(MIC_GAIN, "dB", 0, 1, -8, 47, 20) 36AUDIOHW_SETTING(MIC_GAIN, "dB", 0, 1, -8, 47, 20)
37
38void audiohw_set_recsrc(int source);
37#endif /* HAVE_RECORDING */ 39#endif /* HAVE_RECORDING */
38 40
39#define AKC_NUM_REGS 0x11 41#define AKC_NUM_REGS 0x11
diff --git a/firmware/export/config/samsungyh920.h b/firmware/export/config/samsungyh920.h
index 7d6d590d96..d40a065e00 100644
--- a/firmware/export/config/samsungyh920.h
+++ b/firmware/export/config/samsungyh920.h
@@ -11,7 +11,7 @@
11 11
12/* Define bitmask of input sources - recordable bitmask can be defined 12/* Define bitmask of input sources - recordable bitmask can be defined
13 explicitly if different */ 13 explicitly if different */
14#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN ) 14#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO)
15 15
16/* define the bitmask of hardware sample rates */ 16/* define the bitmask of hardware sample rates */
17#define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ 17#define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \
@@ -133,6 +133,12 @@
133/* AK4537 has no tone controls, so we use the software ones */ 133/* AK4537 has no tone controls, so we use the software ones */
134#define HAVE_SW_TONE_CONTROLS 134#define HAVE_SW_TONE_CONTROLS
135 135
136/* FM Tuner */
137#define CONFIG_TUNER TEA5767
138#define CONFIG_TUNER_XTAL 32768
139/* Define this if the tuner uses 3-wire bus instead of classic i2c */
140#define CONFIG_TUNER_3WIRE
141
136#define AB_REPEAT_ENABLE 142#define AB_REPEAT_ENABLE
137 143
138#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ 144#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */
diff --git a/firmware/export/fmradio_3wire.h b/firmware/export/fmradio_3wire.h
new file mode 100644
index 0000000000..cafce9c8ec
--- /dev/null
+++ b/firmware/export/fmradio_3wire.h
@@ -0,0 +1,33 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 * Physical interface of the Philips TEA5767
10 *
11 * Copyright (C) 2014 by Szymon Dziok
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22#ifndef FMRADIO_TRIWIRE_H
23#define FMRADIO_TRIWIRE_H
24
25#include "config.h" /* for INIT_ATTR */
26#include <stdbool.h>
27
28void fmradio_3wire_init(void) INIT_ATTR;
29void fmradio_3wire_enable(bool enable);
30int fmradio_3wire_write(const unsigned char* buf);
31int fmradio_3wire_read(unsigned char* buf);
32
33#endif
diff --git a/firmware/target/arm/pp/audio-pp.c b/firmware/target/arm/pp/audio-pp.c
index 6b5b082cc7..76740f2e42 100644
--- a/firmware/target/arm/pp/audio-pp.c
+++ b/firmware/target/arm/pp/audio-pp.c
@@ -30,6 +30,25 @@ void audio_set_output_source(int source)
30 source = AUDIO_SRC_PLAYBACK; 30 source = AUDIO_SRC_PLAYBACK;
31} /* audio_set_output_source */ 31} /* audio_set_output_source */
32 32
33#ifdef HAVE_AK4537
34void audio_input_mux(int source, unsigned flags)
35{
36 (void)flags;
37 /* Prevent pops from unneeded switching */
38 static int last_source = AUDIO_SRC_PLAYBACK;
39
40#ifdef HAVE_FMRADIO_REC
41 bool recording = flags & SRCF_RECORDING;
42
43 if ((source == AUDIO_SRC_FMRADIO) && (!recording))
44 audiohw_set_recvol(0, 0, AUDIO_GAIN_LINEIN); /* Set line-in vol to 0dB*/
45#endif
46 if (source != last_source)
47 audiohw_set_recsrc(source);
48
49 last_source = source;
50}
51#else
33void audio_input_mux(int source, unsigned flags) 52void audio_input_mux(int source, unsigned flags)
34{ 53{
35 (void)flags; 54 (void)flags;
@@ -132,4 +151,6 @@ void audio_input_mux(int source, unsigned flags)
132 151
133 last_source = source; 152 last_source = source;
134} /* audio_input_mux */ 153} /* audio_input_mux */
154#endif
155
135#endif /* INPUT_SRC_CAPS != 0 */ 156#endif /* INPUT_SRC_CAPS != 0 */
diff --git a/firmware/target/arm/samsung/fmradio-yh92x.c b/firmware/target/arm/samsung/fmradio-yh92x.c
new file mode 100644
index 0000000000..4637aca287
--- /dev/null
+++ b/firmware/target/arm/samsung/fmradio-yh92x.c
@@ -0,0 +1,120 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 * Physical interface of the Philips TEA5767 in Samsung YH-92x
10 *
11 * Copyright (C) 2014 by Szymon Dziok
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22#include "config.h"
23#include "system.h"
24#include "cpu.h"
25#include "fmradio_3wire.h"
26
27#define CLOCK_EN GPIO_SET_BITWISE(GPIOL_ENABLE, 0x10)
28#define CLOCK_OUT GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x10)
29#define CLOCK_LO GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10)
30#define CLOCK_HI GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10)
31
32#define DATA (GPIOL_INPUT_VAL & 0x08)
33#define DATA_EN GPIO_SET_BITWISE(GPIOL_ENABLE, 0x08)
34#define DATA_IN GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_EN, 0x08)
35#define DATA_OUT GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x08)
36#define DATA_LO GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x08)
37#define DATA_HI GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x08)
38
39#define READWRITE_EN GPIO_SET_BITWISE(GPIOL_ENABLE, 0x01)
40#define READWRITE_OUT GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x01)
41#define READWRITE_LO GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x01)
42#define READWRITE_HI GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x01)
43
44#define DELAY1 udelay(1)
45#define DELAY2 udelay(2)
46
47void fmradio_3wire_init(void)
48{
49 READWRITE_EN;
50 READWRITE_OUT;
51
52 DATA_EN;
53 DATA_IN;
54
55 CLOCK_EN;
56 CLOCK_HI;
57 CLOCK_OUT;
58
59 DELAY2;
60}
61
62int fmradio_3wire_write(const unsigned char* buf)
63{
64 int i, j;
65
66 CLOCK_LO;
67 READWRITE_LO;
68 DELAY2;
69 READWRITE_HI;
70 DELAY1;
71 DATA_OUT;
72
73 /* 5 bytes to the tuner */
74 for (j = 0; j < 5; j++)
75 {
76 for (i = 7; i >= 0; i--)
77 {
78 if ((buf[j] >> i) & 0x1) DATA_HI;
79 else DATA_LO;
80 DELAY1;
81 CLOCK_HI;
82 DELAY2;
83 CLOCK_LO;
84 DELAY1;
85 }
86 }
87 READWRITE_LO;
88
89 return j;
90}
91
92int fmradio_3wire_read(unsigned char* buf)
93{
94 int i, j;
95
96 CLOCK_LO;
97 READWRITE_HI;
98 DELAY2;
99 READWRITE_LO;
100 DELAY2;
101 DATA_IN;
102
103 /* 5 bytes from the tuner */
104 for (j = 0; j < 5; j++)
105 {
106 buf[j] = 0;
107 for (i = 7; i >= 0; i--)
108 {
109 buf[j] |= ((DATA >> 3) << i);
110
111 CLOCK_HI;
112 DELAY2;
113 CLOCK_LO;
114 DELAY2;
115 }
116 }
117 READWRITE_HI;
118
119 return j;
120}
diff --git a/firmware/target/arm/samsung/power-yh82x_yh92x.c b/firmware/target/arm/samsung/power-yh82x_yh92x.c
index 021ddade4d..b6c18c5fd0 100644
--- a/firmware/target/arm/samsung/power-yh82x_yh92x.c
+++ b/firmware/target/arm/samsung/power-yh82x_yh92x.c
@@ -20,7 +20,7 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22/* Created from power.c using some iPod code, and some custom stuff based on 22/* Created from power.c using some iPod code, and some custom stuff based on
23 GPIO analysis 23 GPIO analysis
24*/ 24*/
25 25
26#include "config.h" 26#include "config.h"
@@ -32,9 +32,26 @@
32#include "power.h" 32#include "power.h"
33#include "logf.h" 33#include "logf.h"
34#include "usb.h" 34#include "usb.h"
35#include "fmradio_3wire.h"
36
37#if CONFIG_TUNER
38bool tuner_power(bool status)
39{
40 GPIO_SET_BITWISE(GPIOL_ENABLE, 0x04);
41 GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x04);
42 if (status)
43 GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x04);
44 else
45 GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x04);
46 return status;
47}
48#endif
35 49
36void power_init(void) 50void power_init(void)
37{ 51{
52#if CONFIG_TUNER
53 fmradio_3wire_init();
54#endif
38} 55}
39 56
40unsigned int power_input_status(void) 57unsigned int power_input_status(void)