summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c14
-rw-r--r--firmware/SOURCES6
-rw-r--r--firmware/drivers/tuner/rda5802.c (renamed from firmware/drivers/tuner/fmclipplus.c)167
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/export/config/sansaclipplus.h2
-rw-r--r--firmware/export/rda5802.h (renamed from firmware/export/fmclipplus.h)30
-rw-r--r--firmware/export/tuner.h6
-rw-r--r--firmware/target/arm/as3525/sansa-clipplus/tuner-clipplus.c4
-rw-r--r--firmware/tuner.c16
9 files changed, 126 insertions, 121 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index c5bbd020ef..9b4ba51815 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -2388,19 +2388,19 @@ static int radio_callback(int btn, struct gui_synclist *lists)
2388 } 2388 }
2389 } 2389 }
2390#endif /* SI4700 */ 2390#endif /* SI4700 */
2391#if (CONFIG_TUNER & FMCLIPPLUS) 2391#if (CONFIG_TUNER & RDA5802)
2392 IF_TUNER_TYPE(FMCLIPPLUS) 2392 IF_TUNER_TYPE(RDA5802)
2393 { 2393 {
2394 struct fmclipplus_dbg_info nfo; 2394 struct rda5802_dbg_info nfo;
2395 int i; 2395 int i;
2396 fmclipplus_dbg_info(&nfo); 2396 rda5802_dbg_info(&nfo);
2397 simplelist_addline(SIMPLELIST_ADD_LINE, "FM Clip+ regs:"); 2397 simplelist_addline(SIMPLELIST_ADD_LINE, "RDA5802 regs:");
2398 for (i = 0; i < 32; i += 4) { 2398 for (i = 0; i < 16; i += 4) {
2399 simplelist_addline(SIMPLELIST_ADD_LINE,"%02X: %04X %04X %04X %04X", 2399 simplelist_addline(SIMPLELIST_ADD_LINE,"%02X: %04X %04X %04X %04X",
2400 i, nfo.regs[i], nfo.regs[i+1], nfo.regs[i+2], nfo.regs[i+3]); 2400 i, nfo.regs[i], nfo.regs[i+1], nfo.regs[i+2], nfo.regs[i+3]);
2401 } 2401 }
2402 } 2402 }
2403#endif /* FMCLIPPLUS */ 2403#endif /* RDA55802 */
2404 return ACTION_REDRAW; 2404 return ACTION_REDRAW;
2405} 2405}
2406static bool dbg_fm_radio(void) 2406static bool dbg_fm_radio(void)
diff --git a/firmware/SOURCES b/firmware/SOURCES
index b49382a0e9..1c2922c273 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -248,9 +248,9 @@ drivers/tuner/si4700.c
248#if (CONFIG_TUNER & IPOD_REMOTE_TUNER) 248#if (CONFIG_TUNER & IPOD_REMOTE_TUNER)
249drivers/tuner/ipod_remote_tuner.c 249drivers/tuner/ipod_remote_tuner.c
250#endif /* (CONFIG_TUNER & IPOD_REMOTE_TUNER) */ 250#endif /* (CONFIG_TUNER & IPOD_REMOTE_TUNER) */
251#if (CONFIG_TUNER & FMCLIPPLUS) 251#if (CONFIG_TUNER & RDA5802)
252drivers/tuner/fmclipplus.c 252drivers/tuner/rda5802.c
253#endif /* (CONFIG_TUNER & FMCLIPPLUS) */ 253#endif /* (CONFIG_TUNER & RDA5802) */
254#endif /*SIMULATOR */ 254#endif /*SIMULATOR */
255#endif /* CONFIG_TUNER */ 255#endif /* CONFIG_TUNER */
256#endif /* BOOTLOADER */ 256#endif /* BOOTLOADER */
diff --git a/firmware/drivers/tuner/fmclipplus.c b/firmware/drivers/tuner/rda5802.c
index 1922662d78..a505b6b382 100644
--- a/firmware/drivers/tuner/fmclipplus.c
+++ b/firmware/drivers/tuner/rda5802.c
@@ -7,8 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Tuner "middleware" for unidentified Silicon Labs chip present in some 10 * Tuner "middleware" for RDA5802 chip present in some Sansa Clip+ players
11 * Sansa Clip+ players
12 * 11 *
13 * Copyright (C) 2010 Bertrik Sikken 12 * Copyright (C) 2010 Bertrik Sikken
14 * Copyright (C) 2008 Nils Wallménius (si4700 code that this was based on) 13 * Copyright (C) 2008 Nils Wallménius (si4700 code that this was based on)
@@ -31,7 +30,7 @@
31#include "fmradio.h" 30#include "fmradio.h"
32#include "fmradio_i2c.h" /* physical interface driver */ 31#include "fmradio_i2c.h" /* physical interface driver */
33 32
34#define SEEK_THRESHOLD 0x10 33#define SEEK_THRESHOLD 0x16
35 34
36#define I2C_ADR 0x20 35#define I2C_ADR 0x20
37 36
@@ -50,6 +49,7 @@
50/* POWERCFG (0x2) */ 49/* POWERCFG (0x2) */
51#define POWERCFG_DMUTE (0x1 << 14) 50#define POWERCFG_DMUTE (0x1 << 14)
52#define POWERCFG_MONO (0x1 << 13) 51#define POWERCFG_MONO (0x1 << 13)
52#define POWERCFG_SOFT_RESET (0x1 << 1)
53#define POWERCFG_ENABLE (0x1 << 0) 53#define POWERCFG_ENABLE (0x1 << 0)
54 54
55/* CHANNEL (0x3) */ 55/* CHANNEL (0x3) */
@@ -62,15 +62,20 @@
62 #define CHANNEL_BAND_875_1080 (0x0 << 2) /* tenth-megahertz */ 62 #define CHANNEL_BAND_875_1080 (0x0 << 2) /* tenth-megahertz */
63 #define CHANNEL_BAND_760_1080 (0x1 << 2) 63 #define CHANNEL_BAND_760_1080 (0x1 << 2)
64 #define CHANNEL_BAND_760_900 (0x2 << 2) 64 #define CHANNEL_BAND_760_900 (0x2 << 2)
65 #define CHANNEL_BAND_650_760 (0x3 << 2)
65#define CHANNEL_SPACE (0x3 << 0) 66#define CHANNEL_SPACE (0x3 << 0)
66 #define CHANNEL_SPACEw(x) (((x) << 0) & CHANNEL_SPACE) 67 #define CHANNEL_SPACEw(x) (((x) << 0) & CHANNEL_SPACE)
67 #define CHANNEL_SPACEr(x) (((x) & CHANNEL_SPACE) >> 0) 68 #define CHANNEL_SPACEr(x) (((x) & CHANNEL_SPACE) >> 0)
68 #define CHANNEL_SPACE_200KHZ (0x0 << 0) 69 #define CHANNEL_SPACE_100KHZ (0x0 << 0)
69 #define CHANNEL_SPACE_100KHZ (0x1 << 0) 70 #define CHANNEL_SPACE_200KHZ (0x1 << 0)
70 #define CHANNEL_SPACE_50KHZ (0x2 << 0) 71 #define CHANNEL_SPACE_50KHZ (0x2 << 0)
71 72
72/* SYSCONFIG1 (0x4) */ 73/* SYSCONFIG1 (0x4) */
73#define SYSCONFIG1_DE (0x1 << 11) 74#define SYSCONFIG1_DE (0x1 << 11)
75 #define SYSCONFIG1_SMUTE (0x1 << 9)
76
77/* SYSCONFIG2 (0x5) */
78#define SYSCONFIG2_VOLUME (0xF << 0)
74 79
75/* READCHAN (0xA) */ 80/* READCHAN (0xA) */
76#define READCHAN_READCHAN (0x3ff << 0) 81#define READCHAN_READCHAN (0x3ff << 0)
@@ -79,44 +84,39 @@
79#define READCHAN_ST (0x1 << 10) 84#define READCHAN_ST (0x1 << 10)
80 85
81/* STATUSRSSI (0xB) */ 86/* STATUSRSSI (0xB) */
82#define STATUSRSSI_RSSI (0x3F << 10) 87#define STATUSRSSI_RSSI (0x7F << 9)
83 #define STATUSRSSI_RSSIr(x) (((x) & STATUSRSSI_RSSI) >> 10) 88 #define STATUSRSSI_RSSIr(x) (((x) & STATUSRSSI_RSSI) >> 9)
84#define STATUSRSSI_AFCRL (0x1 << 8) 89#define STATUSRSSI_FM_TRUE (0x1 << 8)
85 90
86static const uint16_t initvals[32] = { 91static const uint16_t initvals[16] = {
87 0x8110, 0x4580, 0xC401, 0x1B90, 92 0x0000, 0x0000, 0xC401, 0x1B90,
88 0x0400, 0x866F, 0x8000, 0x4712, 93 0x0400, 0x866F, 0x8000, 0x4712,
89 0x5EC6, 0x0000, 0x406E, 0x2D80, 94 0x5EC6, 0x0000, 0x406E, 0x2D80,
90 0x5803, 0x5804, 0x5804, 0x5804, 95 0x5803, 0x5804, 0x5804, 0x5804
91
92 0x0047, 0x9000, 0xF587, 0x0009,
93 0x00F1, 0x41C0, 0x41E0, 0x506F,
94 0x5592, 0x007D, 0x10A0, 0x0780,
95 0x311D, 0x4006, 0x1F9B, 0x4C2B
96}; 96};
97 97
98static bool tuner_present = false; 98static bool tuner_present = false;
99static int curr_frequency = 87500000; /* Current station frequency (HZ) */ 99static int curr_frequency = 87500000; /* Current station frequency (HZ) */
100static uint16_t cache[32]; 100static uint16_t cache[16];
101 101
102/* reads <len> registers from radio at offset 0x0A into cache */ 102/* reads <len> registers from radio at offset 0x0A into cache */
103static void fmclipplus_read(int len) 103static void rda5802_read(int len)
104{ 104{
105 int i; 105 int i;
106 unsigned char buf[64]; 106 unsigned char buf[128];
107 unsigned char *ptr = buf; 107 unsigned char *ptr = buf;
108 uint16_t data; 108 uint16_t data;
109 109
110 fmradio_i2c_read(I2C_ADR, buf, len * 2); 110 fmradio_i2c_read(I2C_ADR, buf, len * 2);
111 for (i = 0; i < len; i++) { 111 for (i = 0; i < len; i++) {
112 data = ptr[0] << 8 | ptr[1]; 112 data = ptr[0] << 8 | ptr[1];
113 cache[(i + READCHAN) & 0x1F] = data; 113 cache[READCHAN + i] = data;
114 ptr += 2; 114 ptr += 2;
115 } 115 }
116} 116}
117 117
118/* writes <len> registers from cache to radio at offset 0x02 */ 118/* writes <len> registers from cache to radio at offset 0x02 */
119static void fmclipplus_write(int len) 119static void rda5802_write(int len)
120{ 120{
121 int i; 121 int i;
122 unsigned char buf[64]; 122 unsigned char buf[64];
@@ -124,78 +124,83 @@ static void fmclipplus_write(int len)
124 uint16_t data; 124 uint16_t data;
125 125
126 for (i = 0; i < len; i++) { 126 for (i = 0; i < len; i++) {
127 data = cache[(i + POWERCFG) & 0x1F]; 127 data = cache[POWERCFG + i];
128 *ptr++ = (data >> 8) & 0xFF; 128 *ptr++ = (data >> 8) & 0xFF;
129 *ptr++ = data & 0xFF; 129 *ptr++ = data & 0xFF;
130 } 130 }
131 fmradio_i2c_write(I2C_ADR, buf, len * 2); 131 fmradio_i2c_write(I2C_ADR, buf, len * 2);
132} 132}
133 133
134static uint16_t fmclipplus_read_reg(int reg) 134static uint16_t rda5802_read_reg(int reg)
135{ 135{
136 fmclipplus_read(((reg - READCHAN) & 0x1F) + 1); 136 rda5802_read((reg - READCHAN) + 1);
137 return cache[reg]; 137 return cache[reg];
138} 138}
139 139
140static void fmclipplus_write_reg(int reg, uint16_t value) 140static void rda5802_write_reg(int reg, uint16_t value)
141{ 141{
142 cache[reg] = value; 142 cache[reg] = value;
143} 143}
144 144
145static void fmclipplus_write_cache(void) 145static void rda5802_write_cache(void)
146{
147 rda5802_write(5);
148}
149
150static void rda5802_write_masked(int reg, uint16_t bits, uint16_t mask)
146{ 151{
147 fmclipplus_write(5); 152 rda5802_write_reg(reg, (cache[reg] & ~mask) | (bits & mask));
148} 153}
149 154
150static void fmclipplus_write_masked(int reg, uint16_t bits, uint16_t mask) 155static void rda5802_write_clear(int reg, uint16_t mask)
151{ 156{
152 fmclipplus_write_reg(reg, (cache[reg] & ~mask) | (bits & mask)); 157 rda5802_write_reg(reg, cache[reg] & ~mask);
153} 158}
154 159
155static void fmclipplus_write_clear(int reg, uint16_t mask) 160static void rda5802_write_set(int reg, uint16_t mask)
156{ 161{
157 fmclipplus_write_reg(reg, cache[reg] & ~mask); 162 rda5802_write_reg(reg, cache[reg] | mask);
158} 163}
159 164
160static void fmclipplus_sleep(int snooze) 165static void rda5802_sleep(int snooze)
161{ 166{
162 if (snooze) { 167 if (snooze) {
163 fmclipplus_write_masked(POWERCFG, 0, 0xFF); 168 rda5802_write_clear(POWERCFG, POWERCFG_ENABLE);
164 } 169 }
165 else { 170 else {
166 fmclipplus_write_masked(POWERCFG, 1, 0xFF); 171 rda5802_write_set(POWERCFG, POWERCFG_ENABLE);
167 } 172 }
168 fmclipplus_write_cache(); 173 rda5802_write_cache();
169} 174}
170 175
171bool fmclipplus_detect(void) 176bool rda5802_detect(void)
172{ 177{
173 return ((fmclipplus_read_reg(IDENT) & 0xFF00) == 0x5800); 178 return ((rda5802_read_reg(IDENT) & 0xFF00) == 0x5800);
174 } 179 }
175 180
176void fmclipplus_init(void) 181void rda5802_init(void)
177{ 182{
178 if (fmclipplus_detect()) { 183 if (rda5802_detect()) {
179 tuner_present = true; 184 tuner_present = true;
180 185
181 // send pre-initialisation value 186 // soft-reset
182 fmclipplus_write_reg(POWERCFG, 0x200); 187 rda5802_write_reg(POWERCFG, POWERCFG_SOFT_RESET);
183 fmclipplus_write(2); 188 rda5802_write(1);
184 sleep(HZ * 10 / 100); 189 sleep(HZ * 10 / 1000);
185 190
186 // write initialisation values 191 // write initialisation values
187 memcpy(cache, initvals, sizeof(cache)); 192 memcpy(cache, initvals, sizeof(cache));
188 fmclipplus_write(32); 193 rda5802_write(16);
189 sleep(HZ * 70 / 1000); 194 sleep(HZ * 70 / 1000);
190 } 195 }
191} 196}
192 197
193static void fmclipplus_set_frequency(int freq) 198static void rda5802_set_frequency(int freq)
194{ 199{
195 int i; 200 int i;
201 uint16_t readchan;
196 202
197 /* check BAND and spacings */ 203 /* check BAND and spacings */
198 fmclipplus_read_reg(STATUSRSSI);
199 int start = CHANNEL_BANDr(cache[CHANNEL]) & 1 ? 76000000 : 87000000; 204 int start = CHANNEL_BANDr(cache[CHANNEL]) & 1 ? 76000000 : 87000000;
200 int chan = (freq - start) / 50000; 205 int chan = (freq - start) / 50000;
201 206
@@ -203,92 +208,92 @@ static void fmclipplus_set_frequency(int freq)
203 208
204 for (i = 0; i < 5; i++) { 209 for (i = 0; i < 5; i++) {
205 /* tune and wait a bit */ 210 /* tune and wait a bit */
206 fmclipplus_write_masked(CHANNEL, CHANNEL_CHANw(chan) | CHANNEL_TUNE, 211 rda5802_write_masked(CHANNEL, CHANNEL_CHANw(chan) | CHANNEL_TUNE,
207 CHANNEL_CHAN | CHANNEL_TUNE); 212 CHANNEL_CHAN | CHANNEL_TUNE);
208 fmclipplus_write_cache(); 213 rda5802_write_cache();
209 sleep(HZ * 70 / 1000); 214 sleep(HZ * 70 / 1000);
210 fmclipplus_write_clear(CHANNEL, CHANNEL_TUNE); 215 rda5802_write_clear(CHANNEL, CHANNEL_TUNE);
211 fmclipplus_write_cache(); 216 rda5802_write_cache();
212 217
213 /* check if tuning was successful */ 218 /* check if tuning was successful */
214 fmclipplus_read_reg(STATUSRSSI); 219 readchan = rda5802_read_reg(READCHAN);
215 if (cache[READCHAN] & READCHAN_STC) { 220 if (readchan & READCHAN_STC) {
216 if (READCHAN_READCHANr(cache[READCHAN]) == chan) { 221 if (READCHAN_READCHANr(readchan) == chan) {
217 break; 222 break;
218 } 223 }
219 } 224 }
220 } 225 }
221} 226}
222 227
223static int fmclipplus_tuned(void) 228static int rda5802_tuned(void)
224{ 229{
225 /* Primitive tuning check: sufficient level and AFC not railed */ 230 /* Primitive tuning check: sufficient level and AFC not railed */
226 uint16_t status = fmclipplus_read_reg(STATUSRSSI); 231 uint16_t status = rda5802_read_reg(STATUSRSSI);
227 if (STATUSRSSI_RSSIr(status) >= SEEK_THRESHOLD && 232 if (STATUSRSSI_RSSIr(status) >= SEEK_THRESHOLD &&
228 (status & STATUSRSSI_AFCRL) == 0) { 233 (status & STATUSRSSI_FM_TRUE)) {
229 return 1; 234 return 1;
230 } 235 }
231 236
232 return 0; 237 return 0;
233} 238}
234 239
235static void fmclipplus_set_region(int region) 240static void rda5802_set_region(int region)
236{ 241{
237 const struct fmclipplus_region_data *rd = &fmclipplus_region_data[region]; 242 const struct rda5802_region_data *rd = &rda5802_region_data[region];
238 uint16_t bandspacing = CHANNEL_BANDw(rd->band) | 243 uint16_t bandspacing = CHANNEL_BANDw(rd->band) |
239 CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ); 244 CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ);
240 uint16_t oldbs = cache[CHANNEL] & (CHANNEL_BAND | CHANNEL_SPACE); 245 uint16_t oldbs = cache[CHANNEL] & (CHANNEL_BAND | CHANNEL_SPACE);
241 246
242 fmclipplus_write_masked(SYSCONFIG1, rd->deemphasis ? SYSCONFIG1_DE : 0, 247 rda5802_write_masked(SYSCONFIG1, rd->deemphasis ? SYSCONFIG1_DE : 0,
243 SYSCONFIG1_DE); 248 SYSCONFIG1_DE);
244 fmclipplus_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE); 249 rda5802_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE);
245 fmclipplus_write_cache(); 250 rda5802_write_cache();
246 251
247 /* Retune if this region change would change the channel number. */ 252 /* Retune if this region change would change the channel number. */
248 if (oldbs != bandspacing) { 253 if (oldbs != bandspacing) {
249 fmclipplus_set_frequency(curr_frequency); 254 rda5802_set_frequency(curr_frequency);
250 } 255 }
251} 256}
252 257
253static bool fmclipplus_st(void) 258static bool rda5802_st(void)
254{ 259{
255 return (fmclipplus_read_reg(READCHAN) & READCHAN_ST); 260 return (rda5802_read_reg(READCHAN) & READCHAN_ST);
256} 261}
257 262
258/* tuner abstraction layer: set something to the tuner */ 263/* tuner abstraction layer: set something to the tuner */
259int fmclipplus_set(int setting, int value) 264int rda5802_set(int setting, int value)
260{ 265{
261 switch (setting) { 266 switch (setting) {
262 case RADIO_SLEEP: 267 case RADIO_SLEEP:
263 if (value != 2) { 268 if (value != 2) {
264 fmclipplus_sleep(value); 269 rda5802_sleep(value);
265 } 270 }
266 break; 271 break;
267 272
268 case RADIO_FREQUENCY: 273 case RADIO_FREQUENCY:
269 fmclipplus_set_frequency(value); 274 rda5802_set_frequency(value);
270 break; 275 break;
271 276
272 case RADIO_SCAN_FREQUENCY: 277 case RADIO_SCAN_FREQUENCY:
273 fmclipplus_set_frequency(value); 278 rda5802_set_frequency(value);
274 return fmclipplus_tuned(); 279 return rda5802_tuned();
275 280
276 case RADIO_MUTE: 281 case RADIO_MUTE:
277 fmclipplus_write_masked(POWERCFG, value ? 0 : POWERCFG_DMUTE, 282 rda5802_write_masked(POWERCFG, value ? 0 : POWERCFG_DMUTE,
278 POWERCFG_DMUTE); 283 POWERCFG_DMUTE);
279 fmclipplus_write_masked(SYSCONFIG1, (3 << 9), (3 << 9)); 284 rda5802_write_masked(SYSCONFIG1, (3 << 9), (3 << 9));
280 fmclipplus_write_masked(SYSCONFIG2, (0xF << 0), (0xF << 0)); 285 rda5802_write_set(SYSCONFIG2, SYSCONFIG2_VOLUME);
281 fmclipplus_write_cache(); 286 rda5802_write_cache();
282 break; 287 break;
283 288
284 case RADIO_REGION: 289 case RADIO_REGION:
285 fmclipplus_set_region(value); 290 rda5802_set_region(value);
286 break; 291 break;
287 292
288 case RADIO_FORCE_MONO: 293 case RADIO_FORCE_MONO:
289 fmclipplus_write_masked(POWERCFG, value ? POWERCFG_MONO : 0, 294 rda5802_write_masked(POWERCFG, value ? POWERCFG_MONO : 0,
290 POWERCFG_MONO); 295 POWERCFG_MONO);
291 fmclipplus_write_cache(); 296 rda5802_write_cache();
292 break; 297 break;
293 298
294 default: 299 default:
@@ -299,7 +304,7 @@ int fmclipplus_set(int setting, int value)
299} 304}
300 305
301/* tuner abstraction layer: read something from the tuner */ 306/* tuner abstraction layer: read something from the tuner */
302int fmclipplus_get(int setting) 307int rda5802_get(int setting)
303{ 308{
304 int val = -1; /* default for unsupported query */ 309 int val = -1; /* default for unsupported query */
305 310
@@ -309,20 +314,20 @@ int fmclipplus_get(int setting)
309 break; 314 break;
310 315
311 case RADIO_TUNED: 316 case RADIO_TUNED:
312 val = fmclipplus_tuned(); 317 val = rda5802_tuned();
313 break; 318 break;
314 319
315 case RADIO_STEREO: 320 case RADIO_STEREO:
316 val = fmclipplus_st(); 321 val = rda5802_st();
317 break; 322 break;
318 } 323 }
319 324
320 return val; 325 return val;
321} 326}
322 327
323void fmclipplus_dbg_info(struct fmclipplus_dbg_info *nfo) 328void rda5802_dbg_info(struct rda5802_dbg_info *nfo)
324{ 329{
325 fmclipplus_read(32); 330 rda5802_read(6);
326 memcpy(nfo->regs, cache, sizeof (nfo->regs)); 331 memcpy(nfo->regs, cache, sizeof (nfo->regs));
327} 332}
328 333
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 7f77514116..5be2c99dcb 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -41,7 +41,7 @@
41#define TEA5760 0x10 /* Philips */ 41#define TEA5760 0x10 /* Philips */
42#define LV240000 0x20 /* Sanyo */ 42#define LV240000 0x20 /* Sanyo */
43#define IPOD_REMOTE_TUNER 0x40 /* Apple */ 43#define IPOD_REMOTE_TUNER 0x40 /* Apple */
44#define FMCLIPPLUS 0x80 /* Mystery SiLabs FM tuner in some clip+ */ 44#define RDA5802 0x80 /* RDA Microelectronics */
45 45
46/* CONFIG_CODEC */ 46/* CONFIG_CODEC */
47#define MAS3587F 3587 47#define MAS3587F 3587
diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h
index 90636b152d..df9fad74c9 100644
--- a/firmware/export/config/sansaclipplus.h
+++ b/firmware/export/config/sansaclipplus.h
@@ -123,7 +123,7 @@
123#define AB_REPEAT_ENABLE 1 123#define AB_REPEAT_ENABLE 1
124 124
125/* FM Tuner */ 125/* FM Tuner */
126#define CONFIG_TUNER (SI4700|FMCLIPPLUS) /* in fact SI4702 */ 126#define CONFIG_TUNER (SI4700|RDA5802) /* in fact SI4702 */
127//#define HAVE_TUNER_PWR_CTRL 127//#define HAVE_TUNER_PWR_CTRL
128 128
129/* Define this for LCD backlight available */ 129/* Define this for LCD backlight available */
diff --git a/firmware/export/fmclipplus.h b/firmware/export/rda5802.h
index 20961f47be..e61ecb40ae 100644
--- a/firmware/export/fmclipplus.h
+++ b/firmware/export/rda5802.h
@@ -8,7 +8,7 @@
8 * 8 *
9 * $Id$ 9 * $Id$
10 * 10 *
11 * Tuner header for the Silicon Labs Mystery radio chip in some Sansa Clip+ 11 * Tuner header for the RDA Microelectronics RDA5802 FM tuner chip
12 * 12 *
13 * Copyright (C) 2010 Bertrik Sikken 13 * Copyright (C) 2010 Bertrik Sikken
14 * 14 *
@@ -22,33 +22,33 @@
22 * 22 *
23 ****************************************************************************/ 23 ****************************************************************************/
24 24
25#ifndef _FMCLIPPLUS_H_ 25#ifndef _RDA5802_H_
26#define _FMCLIPPLUS_H_ 26#define _RDA5802_H_
27 27
28#define HAVE_RADIO_REGION 28#define HAVE_RADIO_REGION
29 29
30struct fmclipplus_region_data 30struct rda5802_region_data
31{ 31{
32 unsigned char deemphasis; /* 0: 75us, 1: 50us */ 32 unsigned char deemphasis; /* 0: 75us, 1: 50us */
33 unsigned char band; /* 0: us/europe, 1: japan */ 33 unsigned char band; /* 0: us/europe, 1: japan */
34} __attribute__((packed)); 34} __attribute__((packed));
35 35
36extern const struct fmclipplus_region_data fmclipplus_region_data[TUNER_NUM_REGIONS]; 36extern const struct rda5802_region_data rda5802_region_data[TUNER_NUM_REGIONS];
37 37
38struct fmclipplus_dbg_info 38struct rda5802_dbg_info
39{ 39{
40 uint16_t regs[32]; /* Read registers */ 40 uint16_t regs[16]; /* Read registers */
41}; 41};
42 42
43bool fmclipplus_detect(void); 43bool rda5802_detect(void);
44void fmclipplus_init(void); 44void rda5802_init(void);
45int fmclipplus_set(int setting, int value); 45int rda5802_set(int setting, int value);
46int fmclipplus_get(int setting); 46int rda5802_get(int setting);
47void fmclipplus_dbg_info(struct fmclipplus_dbg_info *nfo); 47void rda5802_dbg_info(struct rda5802_dbg_info *nfo);
48 48
49#ifndef CONFIG_TUNER_MULTI 49#ifndef CONFIG_TUNER_MULTI
50#define tuner_set fmclipplus_set 50#define tuner_set rda5802_set
51#define tuner_get fmclipplus_get 51#define tuner_get rda5802_get
52#endif 52#endif
53 53
54#endif /* _FMCLIPPLUS_H_ */ 54#endif /* _RDA5802_H_ */
diff --git a/firmware/export/tuner.h b/firmware/export/tuner.h
index 9101bb9241..fa894a4b6c 100644
--- a/firmware/export/tuner.h
+++ b/firmware/export/tuner.h
@@ -132,9 +132,9 @@ extern int (*tuner_get)(int setting);
132#include "si4700.h" 132#include "si4700.h"
133#endif 133#endif
134 134
135/* Silicon Labs mystery radio chip in some Sansa Clip+ */ 135/* RDA micro RDA5802 */
136#if (CONFIG_TUNER & FMCLIPPLUS) 136#if (CONFIG_TUNER & RDA5802)
137#include "fmclipplus.h" 137#include "rda5802.h"
138#endif 138#endif
139 139
140/* Apple remote tuner */ 140/* Apple remote tuner */
diff --git a/firmware/target/arm/as3525/sansa-clipplus/tuner-clipplus.c b/firmware/target/arm/as3525/sansa-clipplus/tuner-clipplus.c
index 6bc1294eb4..650f68dc8b 100644
--- a/firmware/target/arm/as3525/sansa-clipplus/tuner-clipplus.c
+++ b/firmware/target/arm/as3525/sansa-clipplus/tuner-clipplus.c
@@ -29,8 +29,8 @@ int tuner_detect_type(void)
29{ 29{
30 if (si4700_detect()) { 30 if (si4700_detect()) {
31 return SI4700; 31 return SI4700;
32 } else if (fmclipplus_detect()) { 32 } else if (rda5802_detect()) {
33 return FMCLIPPLUS; 33 return RDA5802;
34 } else { 34 } else {
35 return 0; 35 return 0;
36 } 36 }
diff --git a/firmware/tuner.c b/firmware/tuner.c
index 4d3866dc8e..3232147bbb 100644
--- a/firmware/tuner.c
+++ b/firmware/tuner.c
@@ -89,8 +89,8 @@ const struct si4700_region_data si4700_region_data[TUNER_NUM_REGIONS] =
89}; 89};
90#endif /* (CONFIG_TUNER & SI4700) */ 90#endif /* (CONFIG_TUNER & SI4700) */
91 91
92#if (CONFIG_TUNER & FMCLIPPLUS) 92#if (CONFIG_TUNER & RDA5802)
93const struct fmclipplus_region_data fmclipplus_region_data[TUNER_NUM_REGIONS] = 93const struct rda5802_region_data rda5802_region_data[TUNER_NUM_REGIONS] =
94{ 94{
95 [REGION_EUROPE] = { 1, 0 }, /* 50uS, US/Europe band */ 95 [REGION_EUROPE] = { 1, 0 }, /* 50uS, US/Europe band */
96 [REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */ 96 [REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */
@@ -99,7 +99,7 @@ const struct fmclipplus_region_data fmclipplus_region_data[TUNER_NUM_REGIONS] =
99 [REGION_ITALY] = { 1, 0 }, /* 50uS, US/Europe band */ 99 [REGION_ITALY] = { 1, 0 }, /* 50uS, US/Europe band */
100 [REGION_OTHER] = { 1, 0 }, /* 50uS, US/Europe band */ 100 [REGION_OTHER] = { 1, 0 }, /* 50uS, US/Europe band */
101}; 101};
102#endif /* (CONFIG_TUNER & FMCLIPPLUS) */ 102#endif /* (CONFIG_TUNER & RDA5802) */
103 103
104#if (CONFIG_TUNER & IPOD_REMOTE_TUNER) 104#if (CONFIG_TUNER & IPOD_REMOTE_TUNER)
105const struct rmt_tuner_region_data 105const struct rmt_tuner_region_data
@@ -163,11 +163,11 @@ void tuner_init(void)
163 si4700_get, 163 si4700_get,
164 si4700_init()) 164 si4700_init())
165 #endif 165 #endif
166 #if (CONFIG_TUNER & FMCLIPPLUS) 166 #if (CONFIG_TUNER & RDA5802)
167 TUNER_TYPE_CASE(FMCLIPPLUS, 167 TUNER_TYPE_CASE(RDA5802,
168 fmclipplus_set, 168 rda5802_set,
169 fmclipplus_get, 169 rda5802_get,
170 fmclipplus_init()) 170 rda5802_init())
171 #endif 171 #endif
172 } 172 }
173} 173}