1
0
Fork 0
forked from len0rd/rockbox

FM tuner region code cleanup - FS #11492 by me.

This removes the tuner-specific region structs and makes each driver use the common one (which is now extended with a deemphasis field)


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27579 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Bertrik Sikken 2010-07-26 20:15:16 +00:00
parent 6087d89603
commit adc472bec5
14 changed files with 53 additions and 162 deletions

View file

@ -177,8 +177,9 @@ void rmt_tuner_region(int region)
{
if (region != old_region)
{
const struct fm_region_data *rd = &fm_region_data[region];
unsigned char data[] = {0x07, 0x08, 0x00};
if (region == 2)
if (rd->freq_min == 76000000)
{
data[2] = 0x02; /* japan band */
}
@ -378,12 +379,14 @@ int ipod_rmt_tuner_set(int setting, int value)
case RADIO_REGION:
{
const struct rmt_tuner_region_data *rd =
&rmt_tuner_region_data[value];
const struct fm_region_data *rd = &fm_region_data[value];
int band = (rd->freq_min == 76000000) ? 2 : 0;
int spacing = (100000 / rd->freq_step);
int deemphasis = (rd->deemphasis == 50) ? 1 : 0;
rmt_tuner_region(rd->band);
set_deltafreq(rd->spacing);
set_deemphasis(rd->deemphasis);
rmt_tuner_region(band);
set_deltafreq(spacing);
set_deemphasis(deemphasis);
rmt_tuner_set_param(tuner_param);
break;
}

View file

@ -938,11 +938,14 @@ int lv24020lp_set(int setting, int value)
break;
case RADIO_REGION:
if (lv24020lp_region_data[value])
{
const struct fm_region_data *rd = &fm_region_data[value];
if (rd->deemphasis == 75)
lv24020lp_write_set(AUDIO_CTRL2, DEEMP);
else
lv24020lp_write_clear(AUDIO_CTRL2, DEEMP);
break;
}
case RADIO_FORCE_MONO:
if (value)

View file

@ -59,16 +59,16 @@
#define CHANNEL_BAND (0x3 << 2)
#define CHANNEL_BANDw(x) (((x) << 2) & CHANNEL_BAND)
#define CHANNEL_BANDr(x) (((x) & CHANNEL_BAND) >> 2)
#define CHANNEL_BAND_875_1080 (0x0 << 2) /* tenth-megahertz */
#define CHANNEL_BAND_760_1080 (0x1 << 2)
#define CHANNEL_BAND_760_900 (0x2 << 2)
#define CHANNEL_BAND_650_760 (0x3 << 2)
#define CHANNEL_BAND_870_1080 (0x0) /* tenth-megahertz */
#define CHANNEL_BAND_760_1080 (0x1)
#define CHANNEL_BAND_760_900 (0x2)
#define CHANNEL_BAND_650_760 (0x3)
#define CHANNEL_SPACE (0x3 << 0)
#define CHANNEL_SPACEw(x) (((x) << 0) & CHANNEL_SPACE)
#define CHANNEL_SPACEr(x) (((x) & CHANNEL_SPACE) >> 0)
#define CHANNEL_SPACE_100KHZ (0x0 << 0)
#define CHANNEL_SPACE_200KHZ (0x1 << 0)
#define CHANNEL_SPACE_50KHZ (0x2 << 0)
#define CHANNEL_SPACE_100KHZ (0x0)
#define CHANNEL_SPACE_200KHZ (0x1)
#define CHANNEL_SPACE_50KHZ (0x2)
/* SYSCONFIG1 (0x4) */
#define SYSCONFIG1_DE (0x1 << 11)
@ -239,13 +239,16 @@ static int rda5802_tuned(void)
static void rda5802_set_region(int region)
{
const struct rda5802_region_data *rd = &rda5802_region_data[region];
uint16_t bandspacing = CHANNEL_BANDw(rd->band) |
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;
uint16_t bandspacing = CHANNEL_BANDw(band) |
CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ);
uint16_t oldbs = cache[CHANNEL] & (CHANNEL_BAND | CHANNEL_SPACE);
rda5802_write_masked(SYSCONFIG1, rd->deemphasis ? SYSCONFIG1_DE : 0,
SYSCONFIG1_DE);
rda5802_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE);
rda5802_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE);
rda5802_write_cache();

View file

@ -400,14 +400,17 @@ static int si4700_tuned(void)
static void si4700_set_region(int region)
{
const struct si4700_region_data *rd = &si4700_region_data[region];
uint16_t bandspacing = SYSCONFIG2_BANDw(rd->band) |
SYSCONFIG2_SPACEw(rd->spacing);
const struct fm_region_data *rd = &fm_region_data[region];
int band = (rd->freq_min == 76000000) ? 2 : 0;
int spacing = (100000 / rd->freq_step);
int deemphasis = (rd->deemphasis == 50) ? SYSCONFIG1_DE : 0;
uint16_t bandspacing = SYSCONFIG2_BANDw(band) |
SYSCONFIG2_SPACEw(spacing);
uint16_t oldbs = cache[SYSCONFIG2] & (SYSCONFIG2_BAND | SYSCONFIG2_SPACE);
si4700_write_masked(SYSCONFIG1,
rd->deemphasis ? SYSCONFIG1_DE : 0,
SYSCONFIG1_DE);
si4700_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE);
si4700_write_masked(SYSCONFIG2, bandspacing,
SYSCONFIG2_BAND | SYSCONFIG2_SPACE);

View file

@ -91,11 +91,12 @@ int tea5760_set(int setting, int value)
case RADIO_REGION:
{
const struct tea5760_region_data *rd =
&tea5760_region_data[value];
const struct fm_region_data *rd = &fm_region_data[value];
int band = (rd->freq_min == 76000000) ? 1 : 0;
int deemphasis = (rd->deemphasis == 50) ? 1 : 0;
tea5760_set_clear(4, (1<<1), rd->deemphasis);
tea5760_set_clear(3, (1<<5), rd->band);
tea5760_set_clear(3, (1<<5), band);
tea5760_set_clear(4, (1<<1), deemphasis);
}
break;

View file

@ -86,11 +86,12 @@ int tea5767_set(int setting, int value)
case RADIO_REGION:
{
const struct tea5767_region_data *rd =
&tea5767_region_data[value];
const struct fm_region_data *rd = &fm_region_data[value];
int deemphasis = (rd->deemphasis == 75) ? 1 : 0;
int band = (rd->freq_min == 76000000) ? 1 : 0;
tea5767_set_clear(4, (1<<6), rd->deemphasis);
tea5767_set_clear(3, (1<<5), rd->band);
tea5767_set_clear(4, (1<<6), deemphasis);
tea5767_set_clear(3, (1<<5), band);
break;
}
case RADIO_FORCE_MONO: