summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-10-19 08:20:38 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-10-19 08:20:38 +0000
commitef8d508d5a276c0e738c0e9d6d1b574a6024f0fb (patch)
treefd823e1f409f3c67e6c45b8e9b213b071e20abf6 /apps
parent2d6eca7e6687e97d30aa60cc6feb526799f6ca2f (diff)
downloadrockbox-ef8d508d5a276c0e738c0e9d6d1b574a6024f0fb.tar.gz
rockbox-ef8d508d5a276c0e738c0e9d6d1b574a6024f0fb.zip
tuner cleanup + improvements:
- use sleep and powerdown for those who can - philips station search works now git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/main.c7
-rw-r--r--apps/recorder/radio.c30
2 files changed, 23 insertions, 14 deletions
diff --git a/apps/main.c b/apps/main.c
index a1483c756d..de23b64e4d 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -196,6 +196,10 @@ void init(void)
196 196
197 powermgmt_init(); 197 powermgmt_init();
198 198
199#ifdef CONFIG_TUNER
200 radio_init();
201#endif
202
199#ifdef HAVE_CHARGING 203#ifdef HAVE_CHARGING
200 if (coldstart && charger_inserted() && !global_settings.car_adapter_mode) 204 if (coldstart && charger_inserted() && !global_settings.car_adapter_mode)
201 { 205 {
@@ -288,9 +292,6 @@ void init(void)
288 global_settings.superbass); 292 global_settings.superbass);
289 mpeg_init(); 293 mpeg_init();
290 talk_init(); 294 talk_init();
291#ifdef CONFIG_TUNER
292 radio_init();
293#endif
294 295
295#ifdef AUTOROCK 296#ifdef AUTOROCK
296 if (!usb_detect()) 297 if (!usb_detect())
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index d60d1bd4d7..125bb5abbb 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -20,7 +20,6 @@
20#include "config.h" 20#include "config.h"
21#include <stdio.h> 21#include <stdio.h>
22#include <stdbool.h> 22#include <stdbool.h>
23#include <stdlib.h>
24#include "sprintf.h" 23#include "sprintf.h"
25#include "lcd.h" 24#include "lcd.h"
26#include "mas.h" 25#include "mas.h"
@@ -116,11 +115,14 @@ void radio_init(void)
116 radio_get = samsung_get; 115 radio_get = samsung_get;
117 } 116 }
118#endif 117#endif
118 radio_set(RADIO_SLEEP, 1); /* low power mode, if available */
119} 119}
120 120
121void radio_stop(void) 121void radio_stop(void)
122{ 122{
123 radio_set(RADIO_MUTE, 1); 123 radio_set(RADIO_MUTE, 1);
124 radio_set(RADIO_SLEEP, 1); /* low power mode, if available */
125 radio_set_status(FMRADIO_OFF); /* status update, power off if avail. */
124} 126}
125 127
126bool radio_hardware_present(void) 128bool radio_hardware_present(void)
@@ -128,7 +130,7 @@ bool radio_hardware_present(void)
128#ifdef HAVE_TUNER_PWR_CTRL 130#ifdef HAVE_TUNER_PWR_CTRL
129 bool ret; 131 bool ret;
130 int fmstatus = radio_get_status(); /* get current state */ 132 int fmstatus = radio_get_status(); /* get current state */
131 radio_set_status(FMRADIO_PLAYING); /* power it up */ 133 radio_set_status(FMRADIO_POWERED); /* power it up */
132 ret = radio_get(RADIO_PRESENT); 134 ret = radio_get(RADIO_PRESENT);
133 radio_set_status(fmstatus); /* restore previous state */ 135 radio_set_status(fmstatus); /* restore previous state */
134 return ret; 136 return ret;
@@ -161,7 +163,7 @@ bool radio_screen(void)
161 bool done = false; 163 bool done = false;
162 int button; 164 int button;
163 int freq; 165 int freq;
164 int freq_diff; 166 bool tuned;
165 bool stereo = false; 167 bool stereo = false;
166 int search_dir = 0; 168 int search_dir = 0;
167 int fw, fh; 169 int fw, fh;
@@ -222,7 +224,7 @@ bool radio_screen(void)
222 224
223 curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ; 225 curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ;
224 226
225 radio_set(RADIO_INIT, 0); 227 radio_set(RADIO_SLEEP, 0); /* wake up the tuner */
226 radio_set(RADIO_FREQUENCY, curr_freq); 228 radio_set(RADIO_FREQUENCY, curr_freq);
227 radio_set(RADIO_IF_MEASUREMENT, 0); 229 radio_set(RADIO_IF_MEASUREMENT, 0);
228 radio_set(RADIO_SENSITIVITY, 0); 230 radio_set(RADIO_SENSITIVITY, 0);
@@ -255,10 +257,10 @@ bool radio_screen(void)
255 sleep(1); 257 sleep(1);
256 258
257 /* Now check how close to the IF frequency we are */ 259 /* Now check how close to the IF frequency we are */
258 freq_diff = radio_get(RADIO_DEVIATION); 260 tuned = radio_get(RADIO_TUNED);
259 261
260 /* Stop searching if the tuning is close */ 262 /* Stop searching if the tuning is close */
261 if(abs(freq_diff) < 50) 263 if(tuned)
262 { 264 {
263 search_dir = 0; 265 search_dir = 0;
264 curr_preset = find_preset(curr_freq); 266 curr_preset = find_preset(curr_freq);
@@ -283,7 +285,6 @@ bool radio_screen(void)
283 else 285 else
284#endif 286#endif
285 { 287 {
286 radio_stop();
287 done = true; 288 done = true;
288 } 289 }
289 update_screen = true; 290 update_screen = true;
@@ -416,7 +417,6 @@ bool radio_screen(void)
416 if(mpeg_status() != MPEG_STATUS_RECORD) 417 if(mpeg_status() != MPEG_STATUS_RECORD)
417 { 418 {
418 default_event_handler(SYS_USB_CONNECTED); 419 default_event_handler(SYS_USB_CONNECTED);
419 radio_set_status(0);
420 screen_freeze = true; /* Cosmetic: makes sure the 420 screen_freeze = true; /* Cosmetic: makes sure the
421 radio screen doesn't redraw */ 421 radio screen doesn't redraw */
422 done = true; 422 done = true;
@@ -540,15 +540,19 @@ bool radio_screen(void)
540 540
541 sound_settings_apply(); 541 sound_settings_apply();
542 542
543 radio_set_status(0);
544
545 if(keep_playing) 543 if(keep_playing)
546 { 544 {
547 /* Enable the Left and right A/D Converter */ 545 /* Enable the Left and right A/D Converter */
548 mpeg_set_recording_gain(mpeg_sound_default(SOUND_LEFT_GAIN), 546 mpeg_set_recording_gain(mpeg_sound_default(SOUND_LEFT_GAIN),
549 mpeg_sound_default(SOUND_RIGHT_GAIN), false); 547 mpeg_sound_default(SOUND_RIGHT_GAIN), false);
550 mas_codec_writereg(6, 0x4000); 548 mas_codec_writereg(6, 0x4000);
549 radio_set_status(FMRADIO_POWERED); /* leave it powered */
550 }
551 else
552 {
553 radio_stop();
551 } 554 }
555
552#endif 556#endif
553 return have_recorded; 557 return have_recorded;
554} 558}
@@ -848,12 +852,16 @@ static bool toggle_mono_mode(void)
848 852
849bool radio_menu(void) 853bool radio_menu(void)
850{ 854{
851 struct menu_item items[3]; 855 struct menu_item items[4];
852 int m; 856 int m;
853 bool result; 857 bool result;
854 858
855 m = menu_init(items, 0, NULL, NULL, NULL, NULL); 859 m = menu_init(items, 0, NULL, NULL, NULL, NULL);
856 860
861#if CONFIG_KEYPAD == ONDIO_PAD /* Ondio has no key for presets, put it in menu */
862 /* fixme: make a real string table entry */
863 menu_insert(m, -1, ID2P(LANG_FM_BUTTONBAR_PRESETS), handle_radio_presets_menu);
864#endif
857 create_monomode_menu(); 865 create_monomode_menu();
858 menu_insert(m, -1, monomode_menu_string, toggle_mono_mode); 866 menu_insert(m, -1, monomode_menu_string, toggle_mono_mode);
859 menu_insert(m, -1, ID2P(LANG_SOUND_SETTINGS), sound_menu); 867 menu_insert(m, -1, ID2P(LANG_SOUND_SETTINGS), sound_menu);