summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2011-12-11 17:38:49 +0000
committerBertrik Sikken <bertrik@sikken.nl>2011-12-11 17:38:49 +0000
commit5515a7a88049391b36d2b53a297c89c832bc8f26 (patch)
tree91f88cf216ce48226dca598c661163b676e6339c
parent6119f4887d3dcbcfe906731c19b86daccd08c4fe (diff)
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.c17
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)
{
int i;
uint16_t readchan;
+ static const int spacings[] = {100000, 200000, 50000, 50000};
+ static const int bandstart[] = {87000000, 76000000, 76000000, 65000000};
- /* check BAND and spacings */
- int start = CHANNEL_BANDr(cache[CHANNEL]) & 1 ? 76000000 : 87000000;
- int chan = (freq - start) / 50000;
+ /* calculate channel number */
+ int start = bandstart[CHANNEL_BANDr(cache[CHANNEL])];
+ int space = spacings[CHANNEL_SPACEr(cache[CHANNEL])];
+ int chan = (freq - start) / space;
for (i = 0; i < 5; i++) {
/* tune and wait a bit */
@@ -247,14 +250,16 @@ static int rda5802_tuned(void)
static void rda5802_set_region(int region)
{
const struct fm_region_data *rd = &fm_region_data[region];
+
int band = (rd->freq_min == 76000000) ?
CHANNEL_BAND_760_900 : CHANNEL_BAND_870_1080;
int deemphasis = (rd->deemphasis == 50) ? SYSCONFIG1_DE : 0;
+ int space = (rd->freq_step == 50000) ?
+ CHANNEL_SPACE_50KHZ : CHANNEL_SPACE_100KHZ;
- uint16_t bandspacing = CHANNEL_BANDw(band) |
- CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ);
rda5802_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE);
- rda5802_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE);
+ rda5802_write_masked(CHANNEL, CHANNEL_BANDw(band), CHANNEL_BAND);
+ rda5802_write_masked(CHANNEL, CHANNEL_SPACEw(space), CHANNEL_SPACE);
rda5802_write_cache();
}