mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
[BugFix] Radio make sure resume frequency is in range
out of range frequencies hang the device (clip zip, others?) Change-Id: I0d3af83a05479f70a958168f57c8cc305195b06b
This commit is contained in:
parent
1189006a4b
commit
30482bd908
1 changed files with 20 additions and 19 deletions
|
@ -167,6 +167,24 @@ bool in_radio_screen(void)
|
||||||
return in_screen;
|
return in_screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Keep freq on the grid for the current region */
|
||||||
|
int snap_freq_to_grid(int freq)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
freq = fmr->freq_min;
|
||||||
|
else if (freq > fmr->freq_max)
|
||||||
|
freq = fmr->freq_max;
|
||||||
|
else
|
||||||
|
freq = (freq - fmr->freq_min + fmr->freq_step/2) /
|
||||||
|
fmr->freq_step * fmr->freq_step + fmr->freq_min;
|
||||||
|
|
||||||
|
return freq;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Move some more of the control functionality to firmware
|
/* TODO: Move some more of the control functionality to firmware
|
||||||
and clean up the mess */
|
and clean up the mess */
|
||||||
|
|
||||||
|
@ -186,7 +204,8 @@ void radio_start(void)
|
||||||
/* clear flag before any yielding */
|
/* clear flag before any yielding */
|
||||||
radio_status &= ~FMRADIO_START_PAUSED;
|
radio_status &= ~FMRADIO_START_PAUSED;
|
||||||
|
|
||||||
curr_freq = global_status.last_frequency * fmr->freq_step + fmr->freq_min;
|
/* ensure the frequency is in range otherwise bad things happen --Bilgus */
|
||||||
|
curr_freq = snap_freq_to_grid(global_status.last_frequency * fmr->freq_step + fmr->freq_min);
|
||||||
|
|
||||||
tuner_set(RADIO_SLEEP, 0); /* wake up the tuner */
|
tuner_set(RADIO_SLEEP, 0); /* wake up the tuner */
|
||||||
|
|
||||||
|
@ -261,24 +280,6 @@ bool radio_hardware_present(void)
|
||||||
return tuner_get(RADIO_PRESENT);
|
return tuner_get(RADIO_PRESENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep freq on the grid for the current region */
|
|
||||||
int snap_freq_to_grid(int freq)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
freq = fmr->freq_min;
|
|
||||||
else if (freq > fmr->freq_max)
|
|
||||||
freq = fmr->freq_max;
|
|
||||||
else
|
|
||||||
freq = (freq - fmr->freq_min + fmr->freq_step/2) /
|
|
||||||
fmr->freq_step * fmr->freq_step + fmr->freq_min;
|
|
||||||
|
|
||||||
return freq;
|
|
||||||
}
|
|
||||||
|
|
||||||
void remember_frequency(void)
|
void remember_frequency(void)
|
||||||
{
|
{
|
||||||
const struct fm_region_data * const fmr =
|
const struct fm_region_data * const fmr =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue