summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-05-03 15:39:40 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-05-03 15:39:40 +0000
commit23b0fdaca1061c86b2d8e71a9f281d5c3e13736b (patch)
tree981168cd3cf72507b39dec55be94b57d5a0a43f9
parent568baaf81a2bcb01fedd22cc88092c6e83cbdd04 (diff)
downloadrockbox-23b0fdaca1061c86b2d8e71a9f281d5c3e13736b.tar.gz
rockbox-23b0fdaca1061c86b2d8e71a9f281d5c3e13736b.zip
Idle poweroff fix for FM radio, as suggested by Mike Holden
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3645 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/recorder/radio.c5
-rw-r--r--firmware/drivers/fmradio.c22
-rw-r--r--firmware/export/fmradio.h4
-rw-r--r--firmware/powermgmt.c6
4 files changed, 25 insertions, 12 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index dc286fb222..4f6fca4fa3 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -69,7 +69,8 @@ bool radio_screen(void)
69 lcd_clear_display(); 69 lcd_clear_display();
70 lcd_setmargins(0, 8); 70 lcd_setmargins(0, 8);
71 status_draw(false); 71 status_draw(false);
72 72 fmradio_set_status(FMRADIO_PLAYING);
73
73 /* Enable the Left and right A/D Converter */ 74 /* Enable the Left and right A/D Converter */
74 mas_codec_writereg(0x0, 0xccc7); 75 mas_codec_writereg(0x0, 0xccc7);
75 76
@@ -182,6 +183,8 @@ bool radio_screen(void)
182 break; 183 break;
183 } 184 }
184 } 185 }
186
187 fmradio_set_status(0);
185 return false; 188 return false;
186} 189}
187#endif 190#endif
diff --git a/firmware/drivers/fmradio.c b/firmware/drivers/fmradio.c
index 0d947f4480..14abb8e2b0 100644
--- a/firmware/drivers/fmradio.c
+++ b/firmware/drivers/fmradio.c
@@ -50,17 +50,7 @@
50/* delay loop */ 50/* delay loop */
51#define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0) 51#define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0)
52 52
53static struct mutex fmradio_mtx; 53static int fmstatus = 0;
54
55void fmradio_begin(void)
56{
57 mutex_lock(&fmradio_mtx);
58}
59
60void fmradio_end(void)
61{
62 mutex_unlock(&fmradio_mtx);
63}
64 54
65int fmradio_read(int addr) 55int fmradio_read(int addr)
66{ 56{
@@ -130,4 +120,14 @@ void fmradio_set(int addr, int data)
130 CE_LO; 120 CE_LO;
131} 121}
132 122
123void fmradio_set_status(int status)
124{
125 fmstatus = status;
126}
127
128int fmradio_get_status(void)
129{
130 return fmstatus;
131}
132
133#endif 133#endif
diff --git a/firmware/export/fmradio.h b/firmware/export/fmradio.h
index 2877501361..b5b239bde1 100644
--- a/firmware/export/fmradio.h
+++ b/firmware/export/fmradio.h
@@ -21,5 +21,9 @@
21 21
22extern int fmradio_read(int addr); 22extern int fmradio_read(int addr);
23extern void fmradio_set(int addr, int data); 23extern void fmradio_set(int addr, int data);
24extern void fmradio_set_status(int status);
25extern int fmradio_get_status(void);
26
27#define FMRADIO_PLAYING 1
24 28
25#endif 29#endif
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index e04e520ad1..00492bbcc6 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -34,6 +34,9 @@
34#include "usb.h" 34#include "usb.h"
35#include "powermgmt.h" 35#include "powermgmt.h"
36#include "backlight.h" 36#include "backlight.h"
37#ifdef HAVE_FMRADIO
38#include "fmradio.h"
39#endif
37 40
38#ifdef SIMULATOR 41#ifdef SIMULATOR
39 42
@@ -299,6 +302,9 @@ static void handle_auto_poweroff(void)
299 charger_was_inserted = charger_is_inserted; 302 charger_was_inserted = charger_is_inserted;
300 303
301 if(timeout && 304 if(timeout &&
305#ifdef HAVE_FMRADIO
306 !fmradio_get_status() &&
307#endif
302 !usb_inserted() && 308 !usb_inserted() &&
303 (mpeg_stat == 0 || 309 (mpeg_stat == 0 ||
304 mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE))) 310 mpeg_stat == (MPEG_STATUS_PLAY | MPEG_STATUS_PAUSE)))