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:
parent
6087d89603
commit
adc472bec5
14 changed files with 53 additions and 162 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -48,19 +48,6 @@ extern void rmt_tuner_signal_power(unsigned char value);
|
|||
|
||||
extern void rmt_tuner_rds_data(void);
|
||||
|
||||
struct rmt_tuner_region_data
|
||||
{
|
||||
/* 0: 50us, 1: 75us */
|
||||
unsigned char deemphasis;
|
||||
/* 0: europe, 1: japan (BL in TEA spec)*/
|
||||
unsigned char band;
|
||||
/* 0: us/australia (200kHz), 1: europe/japan (100kHz), 2: (50kHz) */
|
||||
unsigned char spacing;
|
||||
} __attribute__((packed));
|
||||
|
||||
extern const struct rmt_tuner_region_data
|
||||
rmt_tuner_region_data[TUNER_NUM_REGIONS];
|
||||
|
||||
int ipod_rmt_tuner_set(int setting, int value);
|
||||
int ipod_rmt_tuner_get(int setting);
|
||||
char* ipod_get_rds_info(int setting);
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
#define LV24020LP_DEBUG_FIRST LV24020LP_CTRL_STAT
|
||||
#define LV24020LP_DEBUG_LAST LV24020LP_SD_SET
|
||||
|
||||
const unsigned char lv24020lp_region_data[TUNER_NUM_REGIONS];
|
||||
|
||||
int lv24020lp_set(int setting, int value);
|
||||
int lv24020lp_get(int setting);
|
||||
void lv24020lp_power(bool status);
|
||||
|
|
|
@ -27,14 +27,6 @@
|
|||
|
||||
#define HAVE_RADIO_REGION
|
||||
|
||||
struct rda5802_region_data
|
||||
{
|
||||
unsigned char deemphasis; /* 0: 75us, 1: 50us */
|
||||
unsigned char band; /* 0: us/europe, 1: japan */
|
||||
} __attribute__((packed));
|
||||
|
||||
extern const struct rda5802_region_data rda5802_region_data[TUNER_NUM_REGIONS];
|
||||
|
||||
struct rda5802_dbg_info
|
||||
{
|
||||
uint16_t regs[16]; /* Read registers */
|
||||
|
|
|
@ -27,15 +27,6 @@
|
|||
|
||||
#define HAVE_RADIO_REGION
|
||||
|
||||
struct si4700_region_data
|
||||
{
|
||||
unsigned char deemphasis; /* 0: 75us, 1: 50us */
|
||||
unsigned char band; /* 0: us/europe, 1: japan */
|
||||
unsigned char spacing; /* 0: us/australia (200kHz), 1: europe/japan (100kHz), 2: (50kHz) */
|
||||
} __attribute__((packed));
|
||||
|
||||
extern const struct si4700_region_data si4700_region_data[TUNER_NUM_REGIONS];
|
||||
|
||||
struct si4700_dbg_info
|
||||
{
|
||||
uint16_t regs[16]; /* Read registers */
|
||||
|
|
|
@ -28,14 +28,6 @@
|
|||
|
||||
#define HAVE_RADIO_REGION
|
||||
|
||||
struct tea5760_region_data
|
||||
{
|
||||
unsigned char deemphasis; /* 1: 50us, 0: 75us */
|
||||
unsigned char band; /* 0: europe, 1: japan (BL in TEA spec)*/
|
||||
} __attribute__((packed));
|
||||
|
||||
extern const struct tea5760_region_data tea5760_region_data[TUNER_NUM_REGIONS];
|
||||
|
||||
struct tea5760_dbg_info
|
||||
{
|
||||
unsigned char read_regs[16];
|
||||
|
|
|
@ -26,14 +26,6 @@
|
|||
#define HAVE_RADIO_REGION
|
||||
#define HAVE_RADIO_MUTE_TIMEOUT
|
||||
|
||||
struct tea5767_region_data
|
||||
{
|
||||
unsigned char deemphasis; /* 0: 50us, 1: 75us */
|
||||
unsigned char band; /* 0: europe, 1: japan (BL in TEA spec)*/
|
||||
} __attribute__((packed));
|
||||
|
||||
extern const struct tea5767_region_data tea5767_region_data[TUNER_NUM_REGIONS];
|
||||
|
||||
struct tea5767_dbg_info
|
||||
{
|
||||
unsigned char read_regs[5];
|
||||
|
|
|
@ -84,6 +84,7 @@ struct fm_region_data
|
|||
int freq_min;
|
||||
int freq_max;
|
||||
int freq_step;
|
||||
int deemphasis; /* in microseconds, usually 50 or 75 */
|
||||
};
|
||||
|
||||
extern const struct fm_region_data fm_region_data[TUNER_NUM_REGIONS];
|
||||
|
|
|
@ -28,92 +28,16 @@
|
|||
/* General region information */
|
||||
const struct fm_region_data fm_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = { 87500000, 108000000, 100000 },
|
||||
[REGION_US_CANADA] = { 87900000, 107900000, 200000 },
|
||||
[REGION_JAPAN] = { 76000000, 90000000, 100000 },
|
||||
[REGION_KOREA] = { 87500000, 108000000, 200000 },
|
||||
[REGION_ITALY] = { 87500000, 108000000, 50000 },
|
||||
[REGION_OTHER] = { 87500000, 108000000, 50000 }
|
||||
[REGION_EUROPE] = { 87500000, 108000000, 100000, 50 },
|
||||
[REGION_US_CANADA] = { 87900000, 107900000, 200000, 75 },
|
||||
[REGION_JAPAN] = { 76000000, 90000000, 100000, 50 },
|
||||
[REGION_KOREA] = { 87500000, 108000000, 200000, 50 },
|
||||
[REGION_ITALY] = { 87500000, 108000000, 50000, 50 },
|
||||
[REGION_OTHER] = { 87500000, 108000000, 50000, 50 }
|
||||
};
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* Tuner-specific region information */
|
||||
|
||||
#if (CONFIG_TUNER & LV24020LP)
|
||||
/* deemphasis setting for region */
|
||||
const unsigned char lv24020lp_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = 0, /* 50uS */
|
||||
[REGION_US_CANADA] = 1, /* 75uS */
|
||||
[REGION_JAPAN] = 0, /* 50uS */
|
||||
[REGION_KOREA] = 0, /* 50uS */
|
||||
[REGION_ITALY] = 0, /* 50uS */
|
||||
[REGION_OTHER] = 0, /* 50uS */
|
||||
};
|
||||
#endif /* (CONFIG_TUNER & LV24020LP) */
|
||||
|
||||
#if (CONFIG_TUNER & TEA5760)
|
||||
const struct tea5760_region_data tea5760_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */
|
||||
[REGION_JAPAN] = { 1, 1 }, /* 50uS, Japanese band */
|
||||
[REGION_KOREA] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_ITALY] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_OTHER] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
};
|
||||
#endif /* (CONFIG_TUNER & TEA5760) */
|
||||
|
||||
#if (CONFIG_TUNER & TEA5767)
|
||||
const struct tea5767_region_data tea5767_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = { 0, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_US_CANADA] = { 1, 0 }, /* 75uS, US/Europe band */
|
||||
[REGION_JAPAN] = { 0, 1 }, /* 50uS, Japanese band */
|
||||
[REGION_KOREA] = { 0, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_ITALY] = { 0, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_OTHER] = { 0, 0 }, /* 50uS, US/Europe band */
|
||||
};
|
||||
#endif /* (CONFIG_TUNER & TEA5767) */
|
||||
|
||||
#if (CONFIG_TUNER & SI4700)
|
||||
const struct si4700_region_data si4700_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = { 1, 0, 1 }, /* 50uS, US/Europe band, 100kHz spacing */
|
||||
[REGION_US_CANADA] = { 0, 0, 0 }, /* 75uS, US/Europe band, 200kHz spacing */
|
||||
[REGION_JAPAN] = { 1, 2, 1 }, /* 50uS, Japanese band, 100kHz spacing */
|
||||
[REGION_KOREA] = { 1, 0, 0 }, /* 50uS, US/Europe band, 200kHz spacing */
|
||||
[REGION_ITALY] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
|
||||
[REGION_OTHER] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
|
||||
};
|
||||
#endif /* (CONFIG_TUNER & SI4700) */
|
||||
|
||||
#if (CONFIG_TUNER & RDA5802)
|
||||
const struct rda5802_region_data rda5802_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_US_CANADA] = { 0, 0 }, /* 75uS, US/Europe band */
|
||||
[REGION_JAPAN] = { 1, 1 }, /* 50uS, Japanese band */
|
||||
[REGION_KOREA] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_ITALY] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
[REGION_OTHER] = { 1, 0 }, /* 50uS, US/Europe band */
|
||||
};
|
||||
#endif /* (CONFIG_TUNER & RDA5802) */
|
||||
|
||||
#if (CONFIG_TUNER & IPOD_REMOTE_TUNER)
|
||||
const struct rmt_tuner_region_data
|
||||
rmt_tuner_region_data[TUNER_NUM_REGIONS] =
|
||||
{
|
||||
[REGION_EUROPE] = { 1, 0, 1 }, /* 50uS, US/Europe band, 100kHz spacing */
|
||||
[REGION_US_CANADA] = { 0, 0, 0 }, /* 75uS, US/Europe band, 200kHz spacing */
|
||||
[REGION_JAPAN] = { 1, 2, 1 }, /* 50uS, Japanese band, 100kHz spacing */
|
||||
[REGION_KOREA] = { 1, 0, 0 }, /* 50uS, US/Europe band, 200kHz spacing */
|
||||
[REGION_ITALY] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
|
||||
[REGION_OTHER] = { 1, 0, 2 }, /* 50uS, US/Europe band, 50kHz spacing */
|
||||
};
|
||||
#endif /* (CONFIG_TUNER & IPOD_REMOTE_TUNER) */
|
||||
|
||||
#ifdef CONFIG_TUNER_MULTI
|
||||
int (*tuner_set)(int setting, int value);
|
||||
int (*tuner_get)(int setting);
|
||||
|
|
Loading…
Reference in a new issue