summaryrefslogtreecommitdiff
path: root/firmware/tuner_philips.c
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 /firmware/tuner_philips.c
parent2d6eca7e6687e97d30aa60cc6feb526799f6ca2f (diff)
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 'firmware/tuner_philips.c')
-rw-r--r--firmware/tuner_philips.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/firmware/tuner_philips.c b/firmware/tuner_philips.c
index 3fdf0f7cd0..68b0938348 100644
--- a/firmware/tuner_philips.c
+++ b/firmware/tuner_philips.c
@@ -20,6 +20,8 @@
#include <stdbool.h>
#include <string.h>
+#include <stdlib.h>
+#include "kernel.h"
#include "tuner.h" /* tuner abstraction interface */
#include "fmradio_i2c.h" /* physical interface driver */
@@ -31,8 +33,17 @@ void philips_set(int setting, int value)
{
switch(setting)
{
- case RADIO_INIT:
- memset(write_bytes, 0, sizeof(write_bytes));
+ case RADIO_SLEEP:
+ /* init values */
+ write_bytes[0] = 0x80; /* mute */
+ write_bytes[1] = 0x00;
+ write_bytes[2] = 0x00;
+ write_bytes[3] = 0x0A; /* soft mute, stereo noise cancelling */
+ write_bytes[4] = 0x00;
+ if (value) /* sleep */
+ {
+ write_bytes[3] |= 0x40; /* standby mode */
+ }
break;
case RADIO_FREQUENCY:
@@ -53,8 +64,6 @@ void philips_set(int setting, int value)
fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
break;
- case RADIO_IF_MEASUREMENT:
- case RADIO_SENSITIVITY:
default:
return;
}
@@ -75,14 +84,25 @@ int philips_get(int setting)
val = 1; /* true */
break;
- case RADIO_DEVIATION:
- val = read_bytes[2] & 0x7F;
- val = 222 - val*4; /* convert to kHz */
+ case RADIO_TUNED:
+ val = 0;
+ if (read_bytes[0] & 0x80) /* ready */
+ {
+ val = read_bytes[2] & 0x7F; /* IF counter */
+ val = (abs(val - 0x36) < 2); /* close match */
+ }
break;
case RADIO_STEREO:
val = read_bytes[2] >> 7;
break;
+
+ case RADIO_ALL: /* debug query */
+ val = read_bytes[0] << 24
+ | read_bytes[1] << 16
+ | read_bytes[2] << 8
+ | read_bytes[3];
+ break;
}
return val;
}