summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-10-17 08:53:18 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-10-17 08:53:18 +0000
commit91f9350cbde2653034840fc930749e2b1f9af9c7 (patch)
tree4c669ffda33c468e22266d3b3bb9587b47ff706f
parent79afbafa669bee52059d980ae887dfa06948c252 (diff)
downloadrockbox-91f9350cbde2653034840fc930749e2b1f9af9c7.tar.gz
rockbox-91f9350cbde2653034840fc930749e2b1f9af9c7.zip
moved and renamed fmradio_set/get_status to power.c, where it now additionally serves well for tuner power enable on OndioFM
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5296 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/recorder/radio.c7
-rw-r--r--firmware/drivers/fmradio.c11
-rw-r--r--firmware/drivers/power.c31
-rw-r--r--firmware/export/config-ondiofm.h3
-rw-r--r--firmware/export/fmradio.h5
-rw-r--r--firmware/export/power.h6
-rw-r--r--firmware/powermgmt.c2
-rw-r--r--uisimulator/common/fmradio.c10
8 files changed, 46 insertions, 29 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 8eaff1d917..45a02d5332 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -49,6 +49,7 @@
49#include "talk.h" 49#include "talk.h"
50#include "tuner.h" 50#include "tuner.h"
51#include "hwcompat.h" 51#include "hwcompat.h"
52#include "power.h"
52 53
53#ifdef CONFIG_TUNER 54#ifdef CONFIG_TUNER
54 55
@@ -168,7 +169,7 @@ bool radio_screen(void)
168 lcd_clear_display(); 169 lcd_clear_display();
169 lcd_setmargins(0, 8); 170 lcd_setmargins(0, 8);
170 status_draw(true); 171 status_draw(true);
171 fmradio_set_status(FMRADIO_PLAYING); 172 radio_set_status(FMRADIO_PLAYING);
172 173
173 font_get(FONT_UI); 174 font_get(FONT_UI);
174 lcd_getstringsize("M", &fw, &fh); 175 lcd_getstringsize("M", &fw, &fh);
@@ -405,7 +406,7 @@ bool radio_screen(void)
405 if(mpeg_status() != MPEG_STATUS_RECORD) 406 if(mpeg_status() != MPEG_STATUS_RECORD)
406 { 407 {
407 default_event_handler(SYS_USB_CONNECTED); 408 default_event_handler(SYS_USB_CONNECTED);
408 fmradio_set_status(0); 409 radio_set_status(0);
409 screen_freeze = true; /* Cosmetic: makes sure the 410 screen_freeze = true; /* Cosmetic: makes sure the
410 radio screen doesn't redraw */ 411 radio screen doesn't redraw */
411 done = true; 412 done = true;
@@ -529,7 +530,7 @@ bool radio_screen(void)
529 530
530 sound_settings_apply(); 531 sound_settings_apply();
531 532
532 fmradio_set_status(0); 533 radio_set_status(0);
533 534
534 if(keep_playing) 535 if(keep_playing)
535 { 536 {
diff --git a/firmware/drivers/fmradio.c b/firmware/drivers/fmradio.c
index a0394b2a57..b7b245e0ce 100644
--- a/firmware/drivers/fmradio.c
+++ b/firmware/drivers/fmradio.c
@@ -46,7 +46,6 @@
46/* delay loop */ 46/* delay loop */
47#define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0) 47#define DELAY do { int _x; for(_x=0;_x<10;_x++);} while (0)
48 48
49static int fmstatus = 0;
50 49
51int fmradio_read(int addr) 50int fmradio_read(int addr)
52{ 51{
@@ -116,14 +115,4 @@ void fmradio_set(int addr, int data)
116 CE_LO; 115 CE_LO;
117} 116}
118 117
119void fmradio_set_status(int status)
120{
121 fmstatus = status;
122}
123
124int fmradio_get_status(void)
125{
126 return fmstatus;
127}
128
129#endif 118#endif
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index d05d0ce97f..35aceb50e9 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -28,6 +28,32 @@
28bool charger_enabled; 28bool charger_enabled;
29#endif 29#endif
30 30
31
32#ifdef CONFIG_TUNER
33
34static int fmstatus = 0;
35
36void radio_set_status(int status)
37{
38 fmstatus = status;
39#ifdef HAVE_TUNER_PWR_CTRL
40 if (status)
41 {
42 and_b(~0x04, &PADR); /* drive PA2 low for tuner enable */
43 sleep(1); /* let the voltage settle */
44 }
45 else
46 or_b(0x04, &PADR); /* drive PA2 high for tuner disable */
47#endif
48}
49
50int radio_get_status(void)
51{
52 return fmstatus;
53}
54
55#endif /* #ifdef CONFIG_TUNER */
56
31#ifndef SIMULATOR 57#ifndef SIMULATOR
32 58
33void power_init(void) 59void power_init(void)
@@ -36,6 +62,11 @@ void power_init(void)
36 or_b(0x20, &PBIORL); /* Set charging control bit to output */ 62 or_b(0x20, &PBIORL); /* Set charging control bit to output */
37 charger_enable(false); /* Default to charger OFF */ 63 charger_enable(false); /* Default to charger OFF */
38#endif 64#endif
65#ifdef HAVE_TUNER_PWR_CTRL
66 and_b(~0x30, &PACR2); /* GPIO for PA2 */
67 or_b(0x04, &PADR); /* drive PA2 high for tuner disable */
68 or_b(0x04, &PAIOR); /* output for PA2 */
69#endif
39} 70}
40 71
41bool charger_inserted(void) 72bool charger_inserted(void)
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index f459934fbc..53bb7f2bc4 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -43,6 +43,9 @@
43/* Define this if you have an FM Radio */ 43/* Define this if you have an FM Radio */
44#define CONFIG_TUNER (S1A0903X01 | TEA5767) /* to be decided at runtime */ 44#define CONFIG_TUNER (S1A0903X01 | TEA5767) /* to be decided at runtime */
45 45
46/* Define this if the tuner is switched on by software */
47#define HAVE_TUNER_PWR_CTRL
48
46/* How to detect USB */ 49/* How to detect USB */
47#define USB_FMRECORDERSTYLE 1 /* like FM, on AN1 */ 50#define USB_FMRECORDERSTYLE 1 /* like FM, on AN1 */
48 51
diff --git a/firmware/export/fmradio.h b/firmware/export/fmradio.h
index b5b239bde1..3c55fb7672 100644
--- a/firmware/export/fmradio.h
+++ b/firmware/export/fmradio.h
@@ -6,6 +6,7 @@
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * Driver to control the (Samsung) tuner via port-banging SPI
9 * 10 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing 11 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 * 12 *
@@ -21,9 +22,5 @@
21 22
22extern int fmradio_read(int addr); 23extern int fmradio_read(int addr);
23extern void fmradio_set(int addr, int data); 24extern 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
28 25
29#endif 26#endif
diff --git a/firmware/export/power.h b/firmware/export/power.h
index 54d8ca1419..3ced9fc38b 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -30,4 +30,10 @@ void ide_power_enable(bool on);
30bool ide_powered(void); 30bool ide_powered(void);
31void power_off(void); 31void power_off(void);
32 32
33#ifdef CONFIG_TUNER
34#define FMRADIO_PLAYING 1
35extern void radio_set_status(int status);
36extern int radio_get_status(void);
37#endif
38
33#endif 39#endif
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 35b311a9e8..7d67ec2f5b 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -322,7 +322,7 @@ static void handle_auto_poweroff(void)
322 322
323 if(timeout && 323 if(timeout &&
324#ifdef CONFIG_TUNER 324#ifdef CONFIG_TUNER
325 !fmradio_get_status() && 325 !radio_get_status() &&
326#endif 326#endif
327 !usb_inserted() && 327 !usb_inserted() &&
328 (mpeg_stat == 0 || 328 (mpeg_stat == 0 ||
diff --git a/uisimulator/common/fmradio.c b/uisimulator/common/fmradio.c
index a4cbd7977c..49c7234e06 100644
--- a/uisimulator/common/fmradio.c
+++ b/uisimulator/common/fmradio.c
@@ -45,14 +45,4 @@ void fmradio_set(int addr, int data)
45 fmradio_reg[addr] = data; 45 fmradio_reg[addr] = data;
46} 46}
47 47
48void fmradio_set_status(int status)
49{
50 fmstatus = status;
51}
52
53int fmradio_get_status(void)
54{
55 return fmstatus;
56}
57
58#endif 48#endif