summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-02-05 15:58:10 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-02-25 15:59:08 +0100
commit906e90eb7b036214b2ee48ad2219e1ef679ee7d1 (patch)
tree79d581f2d79a4a6ca4ad63824d0c3082c6c4d453 /firmware
parent58b226edc51f260a19cf0655bbec67622ebe7cef (diff)
Move radio power handling from apps/ to drivers.
Remove direct calls to tuner_power(...) in apps/ and let the driver manage tuner power with the RADIO_SLEEP setting. Change-Id: I37cd0472e60db5d666dae1b9fe4755dd65c03edd Reviewed-on: http://gerrit.rockbox.org/84 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/tuner/ipod_remote_tuner.c13
-rw-r--r--firmware/drivers/tuner/lv24020lp.c3
-rw-r--r--firmware/drivers/tuner/rda5802.c3
-rw-r--r--firmware/drivers/tuner/s1a0903x01.c6
-rw-r--r--firmware/drivers/tuner/si4700.c42
-rw-r--r--firmware/drivers/tuner/tea5760uk.c2
-rw-r--r--firmware/drivers/tuner/tea5767.c4
7 files changed, 39 insertions, 34 deletions
diff --git a/firmware/drivers/tuner/ipod_remote_tuner.c b/firmware/drivers/tuner/ipod_remote_tuner.c
index ad84cb9890..8b599cb79c 100644
--- a/firmware/drivers/tuner/ipod_remote_tuner.c
+++ b/firmware/drivers/tuner/ipod_remote_tuner.c
@@ -31,8 +31,6 @@
#include "settings.h"
#include "power.h"
-static bool powered = false;
-
static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF;
/* temp var for tests to avoid looping execution in submenus settings*/
static int mono_mode = -1, old_region = -1;
@@ -150,7 +148,6 @@ static void rmt_tuner_scan(int param)
iap_send_pkt(data1, sizeof(data1));
}
-#if 0 /* function is not used */
static void rmt_tuner_mute(int value)
{
/* mute flag off (play) */
@@ -162,7 +159,6 @@ static void rmt_tuner_mute(int value)
}
iap_send_pkt(data, sizeof(data));
}
-#endif
static void rmt_tuner_region(int region)
{
@@ -362,7 +358,7 @@ int ipod_rmt_tuner_set(int setting, int value)
case RADIO_MUTE:
{
/* mute flag sent to accessory */
- /* rmt_tuner_mute(value); */
+ rmt_tuner_mute(value);
break;
}
@@ -453,10 +449,3 @@ char* ipod_get_rds_info(int setting)
}
return text;
}
-
-bool tuner_power(bool status)
-{
- bool oldstatus = powered;
- powered = status;
- return oldstatus;
-}
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index 590ca9641e..34fa0df9e2 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -740,6 +740,8 @@ static int sd_setcmp(int regval)
static void set_sleep(bool sleep)
{
+ if (sleep)
+ tuner_power(false);
if (sleep || tuner_awake())
return;
@@ -747,6 +749,7 @@ static void set_sleep(bool sleep)
(TUNER_PRESENT | TUNER_POWERED))
return;
+ tuner_power(true);
enable_afc(false);
/* 2. Calibrate the IF frequency at 110 kHz: */
diff --git a/firmware/drivers/tuner/rda5802.c b/firmware/drivers/tuner/rda5802.c
index c07adc1f07..a6c73a5e21 100644
--- a/firmware/drivers/tuner/rda5802.c
+++ b/firmware/drivers/tuner/rda5802.c
@@ -177,9 +177,12 @@ static void rda5802_sleep(int snooze)
rda5802_write_clear(POWERCFG, POWERCFG_ENABLE);
}
else {
+ tuner_power(true);
rda5802_write_set(POWERCFG, POWERCFG_ENABLE);
}
rda5802_write_cache();
+ if(snooze)
+ tuner_power(false);
}
bool rda5802_detect(void)
diff --git a/firmware/drivers/tuner/s1a0903x01.c b/firmware/drivers/tuner/s1a0903x01.c
index 2c93ebdaad..91d1319fb5 100644
--- a/firmware/drivers/tuner/s1a0903x01.c
+++ b/firmware/drivers/tuner/s1a0903x01.c
@@ -47,12 +47,16 @@ int s1a0903x01_set(int setting, int value)
{
case RADIO_SLEEP:
if (!value)
- { /* wakeup: just unit */
+ {
+ tuner_power(true);
+ /* wakeup: just unit */
fm_in1 = DEFAULT_IN1;
fm_in2 = DEFAULT_IN2;
fmradio_set(1, fm_in1);
fmradio_set(2, fm_in2);
}
+ else
+ tuner_power(false);
/* else we have no sleep mode? */
break;
diff --git a/firmware/drivers/tuner/si4700.c b/firmware/drivers/tuner/si4700.c
index 6966891a38..a5b004aef4 100644
--- a/firmware/drivers/tuner/si4700.c
+++ b/firmware/drivers/tuner/si4700.c
@@ -304,9 +304,20 @@ static void si4700_sleep(int snooze)
POWERCFG_DISABLE | POWERCFG_ENABLE);
/* Bits self-clear once placed in powerdown. */
cache[POWERCFG] &= ~(POWERCFG_DISABLE | POWERCFG_ENABLE);
+
+ tuner_power(false);
}
else
{
+ tuner_power(true);
+ /* read all registers */
+ si4700_read(16);
+#ifdef SI4700_USE_INTERNAL_OSCILLATOR
+ /* Enable the internal oscillator
+ (Si4702-16 needs this register to be initialised to 0x100) */
+ si4700_write_set(TEST1, TEST1_XOSCEN | 0x100);
+ sleep(HZ/2);
+#endif
/** power up **/
/* ENABLE high, DISABLE low */
si4700_write_masked(POWERCFG, POWERCFG_ENABLE,
@@ -354,26 +365,9 @@ bool si4700_detect(void)
void si4700_init(void)
{
+ mutex_init(&fmr_mutex);
/* check device id */
if (si4700_detect()) {
- mutex_init(&fmr_mutex);
-
- tuner_power(true);
-
- /* read all registers */
- si4700_read(16);
- si4700_sleep(0);
-
-#ifdef SI4700_USE_INTERNAL_OSCILLATOR
- /* Enable the internal oscillator
- (Si4702-16 needs this register to be initialised to 0x100) */
- si4700_write_set(TEST1, TEST1_XOSCEN | 0x100);
- sleep(HZ/2);
-#endif
-
- si4700_sleep(1);
- tuner_power(false);
-
#ifdef HAVE_RDS_CAP
si4700_rds_init();
#endif
@@ -445,6 +439,9 @@ int si4700_set(int setting, int value)
{
int val = 1;
+ if(!tuner_powered() && setting != RADIO_SLEEP)
+ return -1;
+
mutex_lock(&fmr_mutex);
switch(setting)
@@ -483,7 +480,7 @@ int si4700_set(int setting, int value)
si4700_write_masked(POWERCFG, value ? POWERCFG_MONO : 0,
POWERCFG_MONO);
break;
-
+
default:
val = -1;
break;
@@ -499,12 +496,15 @@ int si4700_get(int setting)
{
int val = -1; /* default for unsupported query */
+ if(!tuner_powered() && setting != RADIO_PRESENT)
+ return -1;
+
mutex_lock(&fmr_mutex);
switch(setting)
{
case RADIO_PRESENT:
- val = tuner_present ? 1 : 0;
+ val = tuner_present;
break;
case RADIO_TUNED:
@@ -526,7 +526,7 @@ int si4700_get(int setting)
case RADIO_RSSI_MAX:
val = RSSI_MAX;
break;
-
+
#ifdef HAVE_RDS_CAP
case RADIO_EVENT:
{
diff --git a/firmware/drivers/tuner/tea5760uk.c b/firmware/drivers/tuner/tea5760uk.c
index c1dff598b3..0e2e208693 100644
--- a/firmware/drivers/tuner/tea5760uk.c
+++ b/firmware/drivers/tuner/tea5760uk.c
@@ -61,8 +61,10 @@ int tea5760_set(int setting, int value)
if (value) {
/* sleep / standby mode */
tea5760_set_clear(3, (1<<6), 0);
+ tuner_power(false);
}
else {
+ tuner_power(true);
/* active mode */
tea5760_set_clear(3, (1<<6), 1);
/* disable hard mute */
diff --git a/firmware/drivers/tuner/tea5767.c b/firmware/drivers/tuner/tea5767.c
index 3f3af68602..da12a9bb05 100644
--- a/firmware/drivers/tuner/tea5767.c
+++ b/firmware/drivers/tuner/tea5767.c
@@ -106,7 +106,11 @@ int tea5767_set(int setting, int value)
return -1;
}
+ if(setting == RADIO_SLEEP && !value)
+ tuner_power(true); /* wakeup */
fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
+ if(setting == RADIO_SLEEP && value)
+ tuner_power(false); /* sleep */
return 1;
}