forked from len0rd/rockbox
Do some planned radio interface cleanup since adding in the LV24020LP.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13880 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b51a20fb9b
commit
7d759f6b9c
23 changed files with 563 additions and 402 deletions
|
@ -1955,27 +1955,27 @@ static int radio_callback(int btn, struct gui_synclist *lists)
|
|||
"HW detected: yes");
|
||||
#if (CONFIG_TUNER & LV24020LP)
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"CTRL_STAT: %02X", sanyo_get(RADIO_ALL) );
|
||||
"CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT) );
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"RADIO_STAT: %02X", sanyo_get(RADIO_REG_STAT));
|
||||
"RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT));
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"MSS_FM: %d kHz", sanyo_get(RADIO_MSS_FM) );
|
||||
"MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM) );
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"MSS_IF: %d Hz", (sanyo_get(RADIO_MSS_IF) ) );
|
||||
"MSS_IF: %d Hz", (lv24020lp_get(LV24020LP_MSS_IF) ) );
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"MSS_SD: %d Hz", (sanyo_get(RADIO_MSS_SD) ) );
|
||||
"MSS_SD: %d Hz", (lv24020lp_get(LV24020LP_MSS_SD) ) );
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"if_set: %d Hz", (sanyo_get(RADIO_IF_SET) ) );
|
||||
"if_set: %d Hz", (lv24020lp_get(LV24020LP_IF_SET) ) );
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"sd_set: %d Hz", (sanyo_get(RADIO_SD_SET) ) );
|
||||
"sd_set: %d Hz", (lv24020lp_get(LV24020LP_SD_SET) ) );
|
||||
#endif
|
||||
#if (CONFIG_TUNER & S1A0903X01)
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
"Samsung regs: %08X", samsung_get(RADIO_ALL));
|
||||
"Samsung regs: %08X", s1a0903x01_get(RADIO_ALL));
|
||||
#endif
|
||||
#if (CONFIG_TUNER & TEA5767)
|
||||
struct philips_dbg_info info;
|
||||
philips_dbg_info(&info);
|
||||
struct tea5767_dbg_info info;
|
||||
tea5767_dbg_info(&info);
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, "Philips regs:");
|
||||
snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN,
|
||||
" Read: %02X %02X %02X %02X %02X",
|
||||
|
|
|
@ -102,18 +102,6 @@
|
|||
#define RADIO_SCAN_MODE 0
|
||||
#define RADIO_PRESET_MODE 1
|
||||
|
||||
static const struct fm_region_setting fm_region[] = {
|
||||
/* Note: Desriptive strings are just for display atm and are not compiled. */
|
||||
[REGION_EUROPE] =
|
||||
FM_REGION_ENTRY("Europe", 87500000, 108000000, 50000, 0, 0),
|
||||
[REGION_US_CANADA] =
|
||||
FM_REGION_ENTRY("US/Canada", 87900000, 107900000, 200000, 1, 0),
|
||||
[REGION_JAPAN] =
|
||||
FM_REGION_ENTRY("Japan", 76000000, 90000000, 100000, 0, 1),
|
||||
[REGION_KOREA] =
|
||||
FM_REGION_ENTRY("Korea", 87500000, 108000000, 100000, 0, 0),
|
||||
};
|
||||
|
||||
static int curr_preset = -1;
|
||||
static int curr_freq;
|
||||
static int radio_mode = RADIO_SCAN_MODE;
|
||||
|
@ -176,66 +164,57 @@ bool in_radio_screen(void)
|
|||
#define FMRADIO_START_PAUSED 0x8000
|
||||
void radio_start(void)
|
||||
{
|
||||
const struct fm_region_setting *fmr;
|
||||
const struct fm_region_data *fmr;
|
||||
bool start_paused;
|
||||
#if CONFIG_TUNER != LV24020LP
|
||||
int mute_timeout;
|
||||
#endif
|
||||
|
||||
if(radio_status == FMRADIO_PLAYING)
|
||||
return;
|
||||
|
||||
fmr = &fm_region[global_settings.fm_region];
|
||||
fmr = &fm_region_data[global_settings.fm_region];
|
||||
|
||||
start_paused = radio_status & FMRADIO_START_PAUSED;
|
||||
/* clear flag before any yielding */
|
||||
radio_status &= ~FMRADIO_START_PAUSED;
|
||||
|
||||
if(radio_status == FMRADIO_OFF)
|
||||
radio_power(true);
|
||||
tuner_power(true);
|
||||
|
||||
curr_freq = global_status.last_frequency
|
||||
* fmr->freq_step + fmr->freq_min;
|
||||
|
||||
radio_set(RADIO_SLEEP, 0); /* wake up the tuner */
|
||||
#if (CONFIG_TUNER & LV24020LP)
|
||||
radio_set(RADIO_REGION, global_settings.fm_region);
|
||||
radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
|
||||
#endif
|
||||
radio_set(RADIO_FREQUENCY, curr_freq);
|
||||
|
||||
#if CONFIG_TUNER != LV24020LP
|
||||
tuner_set(RADIO_SLEEP, 0); /* wake up the tuner */
|
||||
|
||||
if(radio_status == FMRADIO_OFF)
|
||||
{
|
||||
#if (CONFIG_TUNER & S1A0903X01)
|
||||
radio_set(RADIO_IF_MEASUREMENT, 0);
|
||||
radio_set(RADIO_SENSITIVITY, 0);
|
||||
#ifdef HAVE_RADIO_REGION
|
||||
tuner_set(RADIO_REGION, global_settings.fm_region);
|
||||
#endif
|
||||
radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
|
||||
#if (CONFIG_TUNER & TEA5767)
|
||||
radio_set(RADIO_SET_DEEMPHASIS, fmr->deemphasis);
|
||||
radio_set(RADIO_SET_BAND, fmr->band);
|
||||
#endif
|
||||
mute_timeout = current_tick + 1*HZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* paused */
|
||||
mute_timeout = current_tick + 2*HZ;
|
||||
tuner_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
|
||||
}
|
||||
|
||||
while(!radio_get(RADIO_STEREO) && !radio_get(RADIO_TUNED))
|
||||
tuner_set(RADIO_FREQUENCY, curr_freq);
|
||||
|
||||
#ifdef HAVE_RADIO_MUTE_TIMEOUT
|
||||
{
|
||||
if(TIME_AFTER(current_tick, mute_timeout))
|
||||
break;
|
||||
yield();
|
||||
unsigned long mute_timeout = current_tick + HZ;
|
||||
if (radio_status != FMRADIO_OFF)
|
||||
{
|
||||
/* paused */
|
||||
mute_timeout += HZ;
|
||||
}
|
||||
|
||||
while(!tuner_get(RADIO_STEREO) && !tuner_get(RADIO_TUNED))
|
||||
{
|
||||
if(TIME_AFTER(current_tick, mute_timeout))
|
||||
break;
|
||||
yield();
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_TUNER != LV24020LP */
|
||||
#endif
|
||||
|
||||
/* keep radio from sounding initially */
|
||||
if(!start_paused)
|
||||
radio_set(RADIO_MUTE, 0);
|
||||
tuner_set(RADIO_MUTE, 0);
|
||||
|
||||
radio_status = FMRADIO_PLAYING;
|
||||
} /* radio_start */
|
||||
|
@ -251,8 +230,8 @@ void radio_pause(void)
|
|||
radio_start();
|
||||
}
|
||||
|
||||
radio_set(RADIO_MUTE, 1);
|
||||
radio_set(RADIO_SLEEP, 1);
|
||||
tuner_set(RADIO_MUTE, 1);
|
||||
tuner_set(RADIO_SLEEP, 1);
|
||||
|
||||
radio_status = FMRADIO_PAUSED;
|
||||
} /* radio_pause */
|
||||
|
@ -262,30 +241,22 @@ void radio_stop(void)
|
|||
if(radio_status == FMRADIO_OFF)
|
||||
return;
|
||||
|
||||
radio_set(RADIO_MUTE, 1);
|
||||
radio_set(RADIO_SLEEP, 1); /* low power mode, if available */
|
||||
tuner_set(RADIO_MUTE, 1);
|
||||
tuner_set(RADIO_SLEEP, 1); /* low power mode, if available */
|
||||
radio_status = FMRADIO_OFF;
|
||||
radio_power(false); /* status update, power off if avail. */
|
||||
tuner_power(false); /* status update, power off if avail. */
|
||||
} /* radio_stop */
|
||||
|
||||
bool radio_hardware_present(void)
|
||||
{
|
||||
#ifdef HAVE_TUNER_PWR_CTRL
|
||||
bool ret;
|
||||
bool fmstatus = radio_power(true); /* power it up */
|
||||
ret = radio_get(RADIO_PRESENT);
|
||||
radio_power(fmstatus); /* restore previous state */
|
||||
return ret;
|
||||
#else
|
||||
return radio_get(RADIO_PRESENT);
|
||||
#endif
|
||||
return tuner_get(RADIO_PRESENT);
|
||||
}
|
||||
|
||||
/* Keep freq on the grid for the current region */
|
||||
static int snap_freq_to_grid(int freq)
|
||||
{
|
||||
const struct fm_region_setting * const fmr =
|
||||
&fm_region[global_settings.fm_region];
|
||||
const struct fm_region_data * const fmr =
|
||||
&fm_region_data[global_settings.fm_region];
|
||||
|
||||
/* Range clamp if out of range or just round to nearest */
|
||||
if (freq < fmr->freq_min)
|
||||
|
@ -346,9 +317,8 @@ static int find_closest_preset(int freq, int direction)
|
|||
|
||||
static void remember_frequency(void)
|
||||
{
|
||||
const struct fm_region_setting * const fmr =
|
||||
&fm_region[global_settings.fm_region];
|
||||
|
||||
const struct fm_region_data * const fmr =
|
||||
&fm_region_data[global_settings.fm_region];
|
||||
global_status.last_frequency = (curr_freq - fmr->freq_min)
|
||||
/ fmr->freq_step;
|
||||
status_save();
|
||||
|
@ -367,15 +337,15 @@ static void next_preset(int direction)
|
|||
/* Must stay on the current grid for the region */
|
||||
curr_freq = snap_freq_to_grid(presets[curr_preset].frequency);
|
||||
|
||||
radio_set(RADIO_FREQUENCY, curr_freq);
|
||||
tuner_set(RADIO_FREQUENCY, curr_freq);
|
||||
remember_frequency();
|
||||
}
|
||||
|
||||
/* Step to the next or previous frequency */
|
||||
static int step_freq(int freq, int direction)
|
||||
{
|
||||
const struct fm_region_setting * const fmr =
|
||||
&fm_region[global_settings.fm_region];
|
||||
const struct fm_region_data * const fmr =
|
||||
&fm_region_data[global_settings.fm_region];
|
||||
|
||||
freq += direction*fmr->freq_step;
|
||||
|
||||
|
@ -402,12 +372,12 @@ static void next_station(int direction)
|
|||
curr_freq = step_freq(curr_freq, direction);
|
||||
|
||||
if (radio_status == FMRADIO_PLAYING)
|
||||
radio_set(RADIO_MUTE, 1);
|
||||
tuner_set(RADIO_MUTE, 1);
|
||||
|
||||
radio_set(RADIO_FREQUENCY, curr_freq);
|
||||
tuner_set(RADIO_FREQUENCY, curr_freq);
|
||||
|
||||
if (radio_status == FMRADIO_PLAYING)
|
||||
radio_set(RADIO_MUTE, 0);
|
||||
tuner_set(RADIO_MUTE, 0);
|
||||
|
||||
curr_preset = find_preset(curr_freq);
|
||||
remember_frequency();
|
||||
|
@ -417,7 +387,7 @@ static void next_station(int direction)
|
|||
static void end_search(void)
|
||||
{
|
||||
if (search_dir != 0 && radio_status == FMRADIO_PLAYING)
|
||||
radio_set(RADIO_MUTE, 0);
|
||||
tuner_set(RADIO_MUTE, 0);
|
||||
search_dir = 0;
|
||||
}
|
||||
|
||||
|
@ -540,7 +510,7 @@ int radio_screen(void)
|
|||
curr_freq = step_freq(curr_freq, search_dir);
|
||||
update_screen = true;
|
||||
|
||||
if(radio_set(RADIO_SCAN_FREQUENCY, curr_freq))
|
||||
if(tuner_set(RADIO_SCAN_FREQUENCY, curr_freq))
|
||||
{
|
||||
curr_preset = find_preset(curr_freq);
|
||||
remember_frequency();
|
||||
|
@ -671,7 +641,7 @@ int radio_screen(void)
|
|||
else if (dir == 0)
|
||||
{
|
||||
/* Starting auto scan */
|
||||
radio_set(RADIO_MUTE, 1);
|
||||
tuner_set(RADIO_MUTE, 1);
|
||||
update_screen = true;
|
||||
}
|
||||
break;
|
||||
|
@ -847,7 +817,7 @@ int radio_screen(void)
|
|||
/* keep "mono" from always being displayed when paused */
|
||||
if (radio_status != FMRADIO_PAUSED)
|
||||
{
|
||||
stereo = radio_get(RADIO_STEREO) &&
|
||||
stereo = tuner_get(RADIO_STEREO) &&
|
||||
!global_settings.fm_force_mono;
|
||||
|
||||
if(stereo != last_stereo)
|
||||
|
@ -1329,21 +1299,12 @@ static int handle_radio_presets(void)
|
|||
|
||||
void toggle_mono_mode(bool mono)
|
||||
{
|
||||
radio_set(RADIO_FORCE_MONO, mono);
|
||||
tuner_set(RADIO_FORCE_MONO, mono);
|
||||
}
|
||||
|
||||
void set_radio_region(int region)
|
||||
{
|
||||
#if (CONFIG_TUNER & LV24020LP)
|
||||
radio_set(RADIO_REGION, global_settings.fm_region);
|
||||
#endif
|
||||
#if (CONFIG_TUNER & TEA5767)
|
||||
radio_set(RADIO_SET_DEEMPHASIS,
|
||||
fm_region[region].deemphasis);
|
||||
radio_set(RADIO_SET_BAND, fm_region[region].band);
|
||||
#else
|
||||
(void)region;
|
||||
#endif
|
||||
tuner_set(RADIO_REGION, region);
|
||||
next_station(0);
|
||||
remember_frequency();
|
||||
}
|
||||
|
@ -1381,15 +1342,16 @@ static int scan_presets(void)
|
|||
|
||||
if(do_scan)
|
||||
{
|
||||
const struct fm_region_setting * const fmr =
|
||||
&fm_region[global_settings.fm_region];
|
||||
const struct fm_region_data * const fmr =
|
||||
&fm_region_data[global_settings.fm_region];
|
||||
|
||||
char buf[MAX_FMPRESET_LEN + 1];
|
||||
int i;
|
||||
|
||||
curr_freq = fmr->freq_min;
|
||||
num_presets = 0;
|
||||
memset(presets, 0, sizeof(presets));
|
||||
radio_set(RADIO_MUTE, 1);
|
||||
tuner_set(RADIO_MUTE, 1);
|
||||
|
||||
while(curr_freq <= fmr->freq_max)
|
||||
{
|
||||
|
@ -1404,7 +1366,7 @@ static int scan_presets(void)
|
|||
snprintf(buf, MAX_FMPRESET_LEN, str(LANG_FM_SCANNING), freq, frac);
|
||||
gui_syncsplash(0, buf);
|
||||
|
||||
if(radio_set(RADIO_SCAN_FREQUENCY, curr_freq))
|
||||
if(tuner_set(RADIO_SCAN_FREQUENCY, curr_freq))
|
||||
{
|
||||
/* add preset */
|
||||
snprintf(buf, MAX_FMPRESET_LEN,
|
||||
|
@ -1418,7 +1380,7 @@ static int scan_presets(void)
|
|||
}
|
||||
|
||||
if (radio_status == FMRADIO_PLAYING)
|
||||
radio_set(RADIO_MUTE, 0);
|
||||
tuner_set(RADIO_MUTE, 0);
|
||||
|
||||
presets_changed = true;
|
||||
|
||||
|
|
|
@ -44,23 +44,6 @@ struct fmstation
|
|||
char name[MAX_FMPRESET_LEN+1];
|
||||
};
|
||||
|
||||
struct fm_region_setting
|
||||
{
|
||||
int freq_min;
|
||||
int freq_max;
|
||||
int freq_step;
|
||||
#if (CONFIG_TUNER & TEA5767)
|
||||
char deemphasis; /* 0: 50us, 1: 75us */
|
||||
char band; /* 0: europe, 1: japan (BL in TEA spec)*/
|
||||
/* Note: "region" parameter is just for display atm and is not compiled. */
|
||||
#define FM_REGION_ENTRY(region, fmin, fmax, fstep, deemph, band) \
|
||||
{ fmin, fmax, fstep, deemph, band }
|
||||
#else
|
||||
#define FM_REGION_ENTRY(region, fmin, fmax, fstep, deemph, band) \
|
||||
{ fmin, fmax, fstep }
|
||||
#endif
|
||||
};
|
||||
#endif /* CONFIG_TUNER */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* RADIO_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue