diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2011-12-11 17:38:49 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2011-12-11 17:38:49 +0000 |
commit | 5515a7a88049391b36d2b53a297c89c832bc8f26 (patch) | |
tree | 91f88cf216ce48226dca598c661163b676e6339c | |
parent | 6119f4887d3dcbcfe906731c19b86daccd08c4fe (diff) | |
download | rockbox-5515a7a88049391b36d2b53a297c89c832bc8f26.tar.gz rockbox-5515a7a88049391b36d2b53a297c89c832bc8f26.zip |
RDA5802 tuner: use channel spacing of 100 kHz when possible (instead of always 50 kHz)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31213 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/tuner/rda5802.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/firmware/drivers/tuner/rda5802.c b/firmware/drivers/tuner/rda5802.c index e82b5e3893..c07adc1f07 100644 --- a/firmware/drivers/tuner/rda5802.c +++ b/firmware/drivers/tuner/rda5802.c | |||
@@ -208,10 +208,13 @@ static void rda5802_set_frequency(int freq) | |||
208 | { | 208 | { |
209 | int i; | 209 | int i; |
210 | uint16_t readchan; | 210 | uint16_t readchan; |
211 | static const int spacings[] = {100000, 200000, 50000, 50000}; | ||
212 | static const int bandstart[] = {87000000, 76000000, 76000000, 65000000}; | ||
211 | 213 | ||
212 | /* check BAND and spacings */ | 214 | /* calculate channel number */ |
213 | int start = CHANNEL_BANDr(cache[CHANNEL]) & 1 ? 76000000 : 87000000; | 215 | int start = bandstart[CHANNEL_BANDr(cache[CHANNEL])]; |
214 | int chan = (freq - start) / 50000; | 216 | int space = spacings[CHANNEL_SPACEr(cache[CHANNEL])]; |
217 | int chan = (freq - start) / space; | ||
215 | 218 | ||
216 | for (i = 0; i < 5; i++) { | 219 | for (i = 0; i < 5; i++) { |
217 | /* tune and wait a bit */ | 220 | /* tune and wait a bit */ |
@@ -247,14 +250,16 @@ static int rda5802_tuned(void) | |||
247 | static void rda5802_set_region(int region) | 250 | static void rda5802_set_region(int region) |
248 | { | 251 | { |
249 | const struct fm_region_data *rd = &fm_region_data[region]; | 252 | const struct fm_region_data *rd = &fm_region_data[region]; |
253 | |||
250 | int band = (rd->freq_min == 76000000) ? | 254 | int band = (rd->freq_min == 76000000) ? |
251 | CHANNEL_BAND_760_900 : CHANNEL_BAND_870_1080; | 255 | CHANNEL_BAND_760_900 : CHANNEL_BAND_870_1080; |
252 | int deemphasis = (rd->deemphasis == 50) ? SYSCONFIG1_DE : 0; | 256 | int deemphasis = (rd->deemphasis == 50) ? SYSCONFIG1_DE : 0; |
257 | int space = (rd->freq_step == 50000) ? | ||
258 | CHANNEL_SPACE_50KHZ : CHANNEL_SPACE_100KHZ; | ||
253 | 259 | ||
254 | uint16_t bandspacing = CHANNEL_BANDw(band) | | ||
255 | CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ); | ||
256 | rda5802_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE); | 260 | rda5802_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE); |
257 | rda5802_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE); | 261 | rda5802_write_masked(CHANNEL, CHANNEL_BANDw(band), CHANNEL_BAND); |
262 | rda5802_write_masked(CHANNEL, CHANNEL_SPACEw(space), CHANNEL_SPACE); | ||
258 | rda5802_write_cache(); | 263 | rda5802_write_cache(); |
259 | } | 264 | } |
260 | 265 | ||