diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-10-19 08:20:38 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-10-19 08:20:38 +0000 |
commit | ef8d508d5a276c0e738c0e9d6d1b574a6024f0fb (patch) | |
tree | fd823e1f409f3c67e6c45b8e9b213b071e20abf6 /firmware/tuner_philips.c | |
parent | 2d6eca7e6687e97d30aa60cc6feb526799f6ca2f (diff) | |
download | rockbox-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 'firmware/tuner_philips.c')
-rw-r--r-- | firmware/tuner_philips.c | 34 |
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 @@ | |||
20 | 20 | ||
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <stdlib.h> | ||
24 | #include "kernel.h" | ||
23 | #include "tuner.h" /* tuner abstraction interface */ | 25 | #include "tuner.h" /* tuner abstraction interface */ |
24 | #include "fmradio_i2c.h" /* physical interface driver */ | 26 | #include "fmradio_i2c.h" /* physical interface driver */ |
25 | 27 | ||
@@ -31,8 +33,17 @@ void philips_set(int setting, int value) | |||
31 | { | 33 | { |
32 | switch(setting) | 34 | switch(setting) |
33 | { | 35 | { |
34 | case RADIO_INIT: | 36 | case RADIO_SLEEP: |
35 | memset(write_bytes, 0, sizeof(write_bytes)); | 37 | /* init values */ |
38 | write_bytes[0] = 0x80; /* mute */ | ||
39 | write_bytes[1] = 0x00; | ||
40 | write_bytes[2] = 0x00; | ||
41 | write_bytes[3] = 0x0A; /* soft mute, stereo noise cancelling */ | ||
42 | write_bytes[4] = 0x00; | ||
43 | if (value) /* sleep */ | ||
44 | { | ||
45 | write_bytes[3] |= 0x40; /* standby mode */ | ||
46 | } | ||
36 | break; | 47 | break; |
37 | 48 | ||
38 | case RADIO_FREQUENCY: | 49 | case RADIO_FREQUENCY: |
@@ -53,8 +64,6 @@ void philips_set(int setting, int value) | |||
53 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | 64 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); |
54 | break; | 65 | break; |
55 | 66 | ||
56 | case RADIO_IF_MEASUREMENT: | ||
57 | case RADIO_SENSITIVITY: | ||
58 | default: | 67 | default: |
59 | return; | 68 | return; |
60 | } | 69 | } |
@@ -75,14 +84,25 @@ int philips_get(int setting) | |||
75 | val = 1; /* true */ | 84 | val = 1; /* true */ |
76 | break; | 85 | break; |
77 | 86 | ||
78 | case RADIO_DEVIATION: | 87 | case RADIO_TUNED: |
79 | val = read_bytes[2] & 0x7F; | 88 | val = 0; |
80 | val = 222 - val*4; /* convert to kHz */ | 89 | if (read_bytes[0] & 0x80) /* ready */ |
90 | { | ||
91 | val = read_bytes[2] & 0x7F; /* IF counter */ | ||
92 | val = (abs(val - 0x36) < 2); /* close match */ | ||
93 | } | ||
81 | break; | 94 | break; |
82 | 95 | ||
83 | case RADIO_STEREO: | 96 | case RADIO_STEREO: |
84 | val = read_bytes[2] >> 7; | 97 | val = read_bytes[2] >> 7; |
85 | break; | 98 | break; |
99 | |||
100 | case RADIO_ALL: /* debug query */ | ||
101 | val = read_bytes[0] << 24 | ||
102 | | read_bytes[1] << 16 | ||
103 | | read_bytes[2] << 8 | ||
104 | | read_bytes[3]; | ||
105 | break; | ||
86 | } | 106 | } |
87 | return val; | 107 | return val; |
88 | } | 108 | } |