diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2017-01-30 09:52:05 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2017-02-11 22:19:32 -0500 |
commit | fc9695eb47732e1c189e2f033dbd55e5c346e8c4 (patch) | |
tree | 550830e9af67f47e3eb87587770b25d22110f57a /firmware/export | |
parent | 6436c6e749ab04fbd5d97804a6a1c3b3122b326d (diff) | |
download | rockbox-fc9695eb47732e1c189e2f033dbd55e5c346e8c4.tar.gz rockbox-fc9695eb47732e1c189e2f033dbd55e5c346e8c4.zip |
Improve radio RDS driver and framework
* Remove unused bits like the radio event and simplify basic
radio interface. It can be more self-contained with rds.h only
required by radio and tuner code.
* Add post-processing to text a-la Silicon Labs AN243. The chip's
error correction can only do so much; additional checks are highly
recommended. Simply testing for two identical messages in a row
is extremely effective and I've never seen corrupted text since
doing that, even with mediocre reception.
Groups segments must arrive in order, not randomly; logic change
only accepts them in order, starting at 0.
Time readout was made a bit better but really we'd need to use
verbose mode and ensure that no errors were seen during receiving
of time and more checks would be need to have a stable PI. The
text is the important bit anyway.
* Time out of stale text.
* Text is no longer updated until a complete group has been
received, as is specified in the standard. Perhaps go back to
scrolling text lines in the radio screen?
* Add proper character conversion to UTF-8. Only the default G0
table for the moment. The other two could be added in.
* Add variants "RDS_CFG_PROCESS" and "RDS_CFG_PUSH" to allow
the option for processed RDS data to be pushed to the driver and
still do proper post-processing (only text conversion for now for
the latter).
Change-Id: I4d83f8b2e89a209a5096d15ec266477318c66925
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/config.h | 10 | ||||
-rw-r--r-- | firmware/export/config/gigabeats.h | 2 | ||||
-rw-r--r-- | firmware/export/config/ipod4g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipod6g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipodcolor.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipodmini1g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipodmini2g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipodnano1g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipodnano2g.h | 1 | ||||
-rw-r--r-- | firmware/export/config/ipodvideo.h | 1 | ||||
-rw-r--r-- | firmware/export/ipod_remote_tuner.h | 3 | ||||
-rw-r--r-- | firmware/export/rds.h | 39 | ||||
-rw-r--r-- | firmware/export/si4700.h | 28 | ||||
-rw-r--r-- | firmware/export/tuner.h | 19 |
14 files changed, 78 insertions, 31 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h index efad75f1b2..4209955c2d 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -712,6 +712,16 @@ Lyre prototype 1 */ | |||
712 | #define BATTERY_CAPACITY_INC 0 | 712 | #define BATTERY_CAPACITY_INC 0 |
713 | #endif | 713 | #endif |
714 | 714 | ||
715 | #ifdef HAVE_RDS_CAP | ||
716 | /* combinable bitflags */ | ||
717 | #define RDS_CFG_ISR 0x1 /* uses ISR to process packets */ | ||
718 | #define RDS_CFG_PROCESS 0x2 /* uses raw packet processing */ | ||
719 | #define RDS_CFG_PUSH 0x4 /* pushes processed information */ | ||
720 | #ifndef CONFIG_RDS | ||
721 | #define CONFIG_RDS RDS_CFG_PROCESS /* thread processing+raw processing */ | ||
722 | #endif /* CONFIG_RDS */ | ||
723 | #endif /* HAVE_RDS_CAP */ | ||
724 | |||
715 | #ifndef CONFIG_ORIENTATION | 725 | #ifndef CONFIG_ORIENTATION |
716 | #if LCD_HEIGHT > LCD_WIDTH | 726 | #if LCD_HEIGHT > LCD_WIDTH |
717 | #define CONFIG_ORIENTATION SCREEN_PORTRAIT | 727 | #define CONFIG_ORIENTATION SCREEN_PORTRAIT |
diff --git a/firmware/export/config/gigabeats.h b/firmware/export/config/gigabeats.h index e1bbb18529..928e8c0e60 100644 --- a/firmware/export/config/gigabeats.h +++ b/firmware/export/config/gigabeats.h | |||
@@ -121,7 +121,7 @@ | |||
121 | /* Define this if you have a SI4700 fm radio tuner */ | 121 | /* Define this if you have a SI4700 fm radio tuner */ |
122 | #define CONFIG_TUNER SI4700 | 122 | #define CONFIG_TUNER SI4700 |
123 | #define HAVE_RDS_CAP | 123 | #define HAVE_RDS_CAP |
124 | #define RDS_ISR_PROCESSING | 124 | #define CONFIG_RDS (RDS_CFG_ISR | RDS_CFG_PROCESS) |
125 | 125 | ||
126 | /* define this if you can flip your LCD */ | 126 | /* define this if you can flip your LCD */ |
127 | #define HAVE_LCD_FLIP | 127 | #define HAVE_LCD_FLIP |
diff --git a/firmware/export/config/ipod4g.h b/firmware/export/config/ipod4g.h index dc83a594fc..785491a9ab 100644 --- a/firmware/export/config/ipod4g.h +++ b/firmware/export/config/ipod4g.h | |||
@@ -164,6 +164,7 @@ | |||
164 | /* Define Apple remote tuner */ | 164 | /* Define Apple remote tuner */ |
165 | #define CONFIG_TUNER IPOD_REMOTE_TUNER | 165 | #define CONFIG_TUNER IPOD_REMOTE_TUNER |
166 | #define HAVE_RDS_CAP | 166 | #define HAVE_RDS_CAP |
167 | #define CONFIG_RDS RDS_CFG_PUSH | ||
167 | 168 | ||
168 | /* Define this if you have a PortalPlayer PP5020 */ | 169 | /* Define this if you have a PortalPlayer PP5020 */ |
169 | #define CONFIG_CPU PP5020 | 170 | #define CONFIG_CPU PP5020 |
diff --git a/firmware/export/config/ipod6g.h b/firmware/export/config/ipod6g.h index 5494cf387a..7664fd4f90 100644 --- a/firmware/export/config/ipod6g.h +++ b/firmware/export/config/ipod6g.h | |||
@@ -167,6 +167,7 @@ | |||
167 | /* Define Apple remote tuner */ | 167 | /* Define Apple remote tuner */ |
168 | //#define CONFIG_TUNER IPOD_REMOTE_TUNER | 168 | //#define CONFIG_TUNER IPOD_REMOTE_TUNER |
169 | //#define HAVE_RDS_CAP | 169 | //#define HAVE_RDS_CAP |
170 | //#define CONFIG_RDS RDS_CFG_PUSH | ||
170 | 171 | ||
171 | /* The exact type of CPU */ | 172 | /* The exact type of CPU */ |
172 | #define CONFIG_CPU S5L8702 | 173 | #define CONFIG_CPU S5L8702 |
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h index 9f34a7955b..33533f925f 100644 --- a/firmware/export/config/ipodcolor.h +++ b/firmware/export/config/ipodcolor.h | |||
@@ -151,6 +151,7 @@ | |||
151 | /* Define Apple remote tuner */ | 151 | /* Define Apple remote tuner */ |
152 | #define CONFIG_TUNER IPOD_REMOTE_TUNER | 152 | #define CONFIG_TUNER IPOD_REMOTE_TUNER |
153 | #define HAVE_RDS_CAP | 153 | #define HAVE_RDS_CAP |
154 | #define CONFIG_RDS RDS_CFG_PUSH | ||
154 | 155 | ||
155 | /* Define this if you have a PortalPlayer PP5020 */ | 156 | /* Define this if you have a PortalPlayer PP5020 */ |
156 | #define CONFIG_CPU PP5020 | 157 | #define CONFIG_CPU PP5020 |
diff --git a/firmware/export/config/ipodmini1g.h b/firmware/export/config/ipodmini1g.h index 71dfe16c04..4f9f1b3dd9 100644 --- a/firmware/export/config/ipodmini1g.h +++ b/firmware/export/config/ipodmini1g.h | |||
@@ -163,6 +163,7 @@ | |||
163 | /* Define Apple remote tuner */ | 163 | /* Define Apple remote tuner */ |
164 | #define CONFIG_TUNER IPOD_REMOTE_TUNER | 164 | #define CONFIG_TUNER IPOD_REMOTE_TUNER |
165 | #define HAVE_RDS_CAP | 165 | #define HAVE_RDS_CAP |
166 | #define CONFIG_RDS RDS_CFG_PUSH | ||
166 | 167 | ||
167 | /* Define this if you have a PortalPlayer PP5020 */ | 168 | /* Define this if you have a PortalPlayer PP5020 */ |
168 | #define CONFIG_CPU PP5020 | 169 | #define CONFIG_CPU PP5020 |
diff --git a/firmware/export/config/ipodmini2g.h b/firmware/export/config/ipodmini2g.h index a2b199afee..977eb3da3f 100644 --- a/firmware/export/config/ipodmini2g.h +++ b/firmware/export/config/ipodmini2g.h | |||
@@ -164,6 +164,7 @@ | |||
164 | /* Define Apple remote tuner */ | 164 | /* Define Apple remote tuner */ |
165 | #define CONFIG_TUNER IPOD_REMOTE_TUNER | 165 | #define CONFIG_TUNER IPOD_REMOTE_TUNER |
166 | #define HAVE_RDS_CAP | 166 | #define HAVE_RDS_CAP |
167 | #define CONFIG_RDS RDS_CFG_PUSH | ||
167 | 168 | ||
168 | /* Define this if you have a PortalPlayer PP5022 */ | 169 | /* Define this if you have a PortalPlayer PP5022 */ |
169 | #define CONFIG_CPU PP5022 | 170 | #define CONFIG_CPU PP5022 |
diff --git a/firmware/export/config/ipodnano1g.h b/firmware/export/config/ipodnano1g.h index acdfff3c15..81d4a0ae4c 100644 --- a/firmware/export/config/ipodnano1g.h +++ b/firmware/export/config/ipodnano1g.h | |||
@@ -154,6 +154,7 @@ | |||
154 | /* Define Apple remote tuner */ | 154 | /* Define Apple remote tuner */ |
155 | #define CONFIG_TUNER IPOD_REMOTE_TUNER | 155 | #define CONFIG_TUNER IPOD_REMOTE_TUNER |
156 | #define HAVE_RDS_CAP | 156 | #define HAVE_RDS_CAP |
157 | #define CONFIG_RDS RDS_CFG_PUSH | ||
157 | 158 | ||
158 | /* Define this if you have a PortalPlayer PP5022 */ | 159 | /* Define this if you have a PortalPlayer PP5022 */ |
159 | #define CONFIG_CPU PP5022 | 160 | #define CONFIG_CPU PP5022 |
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h index aeff6aeda1..9d8c39ef7e 100644 --- a/firmware/export/config/ipodnano2g.h +++ b/firmware/export/config/ipodnano2g.h | |||
@@ -164,6 +164,7 @@ | |||
164 | /* Define Apple remote tuner */ | 164 | /* Define Apple remote tuner */ |
165 | //#define CONFIG_TUNER IPOD_REMOTE_TUNER | 165 | //#define CONFIG_TUNER IPOD_REMOTE_TUNER |
166 | //#define HAVE_RDS_CAP | 166 | //#define HAVE_RDS_CAP |
167 | //#define CONFIG_RDS RDS_CFG_PUSH | ||
167 | 168 | ||
168 | /* The exact type of CPU */ | 169 | /* The exact type of CPU */ |
169 | #define CONFIG_CPU S5L8701 | 170 | #define CONFIG_CPU S5L8701 |
diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h index 2f28182731..7f1d83f4a5 100644 --- a/firmware/export/config/ipodvideo.h +++ b/firmware/export/config/ipodvideo.h | |||
@@ -170,6 +170,7 @@ | |||
170 | /* Define Apple remote tuner */ | 170 | /* Define Apple remote tuner */ |
171 | #define CONFIG_TUNER IPOD_REMOTE_TUNER | 171 | #define CONFIG_TUNER IPOD_REMOTE_TUNER |
172 | #define HAVE_RDS_CAP | 172 | #define HAVE_RDS_CAP |
173 | #define CONFIG_RDS RDS_CFG_PUSH | ||
173 | 174 | ||
174 | /* Define this if you have a PortalPlayer PP5022 */ | 175 | /* Define this if you have a PortalPlayer PP5022 */ |
175 | #define CONFIG_CPU PP5022 | 176 | #define CONFIG_CPU PP5022 |
diff --git a/firmware/export/ipod_remote_tuner.h b/firmware/export/ipod_remote_tuner.h index 30c83a4135..37bf412f53 100644 --- a/firmware/export/ipod_remote_tuner.h +++ b/firmware/export/ipod_remote_tuner.h | |||
@@ -33,13 +33,10 @@ extern void rmt_tuner_rds_data(unsigned int len, const unsigned char *buf); | |||
33 | 33 | ||
34 | int ipod_rmt_tuner_set(int setting, int value); | 34 | int ipod_rmt_tuner_set(int setting, int value); |
35 | int ipod_rmt_tuner_get(int setting); | 35 | int ipod_rmt_tuner_get(int setting); |
36 | char* ipod_get_rds_info(int setting); | ||
37 | |||
38 | 36 | ||
39 | #ifndef CONFIG_TUNER_MULTI | 37 | #ifndef CONFIG_TUNER_MULTI |
40 | #define tuner_set ipod_rmt_tuner_set | 38 | #define tuner_set ipod_rmt_tuner_set |
41 | #define tuner_get ipod_rmt_tuner_get | 39 | #define tuner_get ipod_rmt_tuner_get |
42 | #define tuner_get_rds_info ipod_get_rds_info | ||
43 | #endif | 40 | #endif |
44 | 41 | ||
45 | #endif /* _IPOD_REMOTE_TUNER_H_ */ | 42 | #endif /* _IPOD_REMOTE_TUNER_H_ */ |
diff --git a/firmware/export/rds.h b/firmware/export/rds.h index ff1608f5c4..6c42e16f56 100644 --- a/firmware/export/rds.h +++ b/firmware/export/rds.h | |||
@@ -18,18 +18,45 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #ifndef RDS_H | ||
22 | #define RDS_H | ||
23 | |||
21 | #include <stdint.h> | 24 | #include <stdint.h> |
22 | #include <stdbool.h> | 25 | #include <stdbool.h> |
23 | #include "time.h" | 26 | #include "time.h" |
24 | 27 | ||
25 | void rds_init(void); | 28 | void rds_init(void); |
26 | |||
27 | void rds_reset(void); | 29 | void rds_reset(void); |
28 | bool rds_process(uint16_t data[4]); | 30 | void rds_sync(void); |
31 | |||
32 | #if (CONFIG_RDS & RDS_CFG_PROCESS) | ||
33 | /* RDS raw data processing */ | ||
34 | void rds_process(const uint16_t data[4]); | ||
35 | #endif /* (CONFIG_RDS & RDS_CFG_PROCESS) */ | ||
36 | |||
37 | enum rds_info_id | ||
38 | { | ||
39 | RDS_INFO_NULL = 0, | ||
40 | RDS_INFO_CODEABLE, /* code table, right now only G0 */ | ||
41 | RDS_INFO_PI, /* programme identifier */ | ||
42 | RDS_INFO_PS, /* programme service name */ | ||
43 | RDS_INFO_RT, /* radio text */ | ||
44 | RDS_INFO_CT, /* clock time */ | ||
45 | }; | ||
46 | |||
47 | enum rds_code_table | ||
48 | { | ||
49 | RDS_CT_G0, /* default code table G0 */ | ||
50 | RDS_CT_G1, /* alternate code table G1 */ | ||
51 | RDS_CT_G2, /* alternate code table G2 */ | ||
52 | }; | ||
29 | 53 | ||
30 | uint16_t rds_get_pi(void); | 54 | #if (CONFIG_RDS & RDS_CFG_PUSH) |
31 | char* rds_get_ps(void); | 55 | /* pushes preprocesed RDS information */ |
32 | char* rds_get_rt(void); | 56 | void rds_push_info(enum rds_info_id info_id, uintptr_t data, size_t size); |
33 | time_t rds_get_ct(void); | 57 | #endif /* (CONFIG_RDS & RDS_CFG_PUSH) */ |
34 | 58 | ||
59 | /* read fully-processed RDS data */ | ||
60 | size_t rds_pull_info(enum rds_info_id info_id, uintptr_t data, size_t size); | ||
35 | 61 | ||
62 | #endif /* RDS_H */ | ||
diff --git a/firmware/export/si4700.h b/firmware/export/si4700.h index 6b7992c025..bd75bf0817 100644 --- a/firmware/export/si4700.h +++ b/firmware/export/si4700.h | |||
@@ -35,36 +35,34 @@ struct si4700_dbg_info | |||
35 | }; | 35 | }; |
36 | 36 | ||
37 | bool si4700_detect(void); | 37 | bool si4700_detect(void); |
38 | void si4700_init(void); | 38 | void si4700_init(void) INIT_ATTR; |
39 | int si4700_set(int setting, int value); | 39 | int si4700_set(int setting, int value); |
40 | int si4700_get(int setting); | 40 | int si4700_get(int setting); |
41 | void si4700_dbg_info(struct si4700_dbg_info *nfo); | 41 | void si4700_dbg_info(struct si4700_dbg_info *nfo); |
42 | /* For interrupt-based mono/stereo indicator */ | 42 | /* For interrupt-based mono/stereo indicator */ |
43 | bool si4700_st(void); | 43 | bool si4700_st(void); |
44 | 44 | ||
45 | #ifdef HAVE_RDS_CAP | ||
45 | /** RDS support **/ | 46 | /** RDS support **/ |
46 | void si4700_rds_init(void); | 47 | |
48 | void si4700_rds_init(void) INIT_ATTR; | ||
47 | /* Radio is fully powered up or about to be powered down */ | 49 | /* Radio is fully powered up or about to be powered down */ |
48 | void si4700_rds_powerup(bool on); | 50 | void si4700_rds_powerup(bool on); |
49 | #ifdef RDS_ISR_PROCESSING | 51 | |
52 | #if (CONFIG_RDS & RDS_CFG_ISR) | ||
50 | /* Read raw RDS info for processing - asynchronously */ | 53 | /* Read raw RDS info for processing - asynchronously */ |
51 | void si4700_read_raw_async(int count); /* implemented by target */ | 54 | void si4700_rds_read_raw_async(unsigned char *buf, int count); /* implemented by target */ |
52 | void si4700_rds_read_raw_async(void); | 55 | void si4700_rds_interrupt(void); |
53 | void si4700_rds_read_raw_async_complete(unsigned char *regbuf, | 56 | #endif /* (CONFIG_RDS & RDS_CFG_ISR) */ |
54 | uint16_t data[4]); | 57 | |
55 | #else /* ndef RDS_ISR_PROCESSING */ | ||
56 | /* Read raw RDS info for processing */ | 58 | /* Read raw RDS info for processing */ |
57 | bool si4700_rds_read_raw(uint16_t data[4]); | 59 | void si4700_rds_process(void); |
58 | #endif /* RDS_ISR_PROCESSING */ | 60 | |
59 | /* Obtain specified string */ | 61 | #endif /* HAVE_RDS_CAP */ |
60 | char* si4700_get_rds_info(int setting); | ||
61 | /* Set the event flag */ | ||
62 | void si4700_rds_set_event(void); | ||
63 | 62 | ||
64 | #ifndef CONFIG_TUNER_MULTI | 63 | #ifndef CONFIG_TUNER_MULTI |
65 | #define tuner_set si4700_set | 64 | #define tuner_set si4700_set |
66 | #define tuner_get si4700_get | 65 | #define tuner_get si4700_get |
67 | #define tuner_get_rds_info si4700_get_rds_info | ||
68 | #endif | 66 | #endif |
69 | 67 | ||
70 | #endif /* _SI4700_H_ */ | 68 | #endif /* _SI4700_H_ */ |
diff --git a/firmware/export/tuner.h b/firmware/export/tuner.h index 050bbd0f33..a166eacf33 100644 --- a/firmware/export/tuner.h +++ b/firmware/export/tuner.h | |||
@@ -25,6 +25,10 @@ | |||
25 | #include "config.h" | 25 | #include "config.h" |
26 | #include "hwcompat.h" | 26 | #include "hwcompat.h" |
27 | 27 | ||
28 | #ifdef HAVE_RDS_CAP | ||
29 | #include <sys/types.h> | ||
30 | #endif | ||
31 | |||
28 | /** Settings to the tuner layer **/ | 32 | /** Settings to the tuner layer **/ |
29 | enum | 33 | enum |
30 | { | 34 | { |
@@ -45,8 +49,6 @@ enum | |||
45 | RADIO_PRESENT = 0, | 49 | RADIO_PRESENT = 0, |
46 | RADIO_TUNED, | 50 | RADIO_TUNED, |
47 | RADIO_STEREO, | 51 | RADIO_STEREO, |
48 | /* RADIO_EVENT is an event that requests a screen update */ | ||
49 | RADIO_EVENT, | ||
50 | RADIO_RSSI, | 52 | RADIO_RSSI, |
51 | RADIO_RSSI_MIN, | 53 | RADIO_RSSI_MIN, |
52 | RADIO_RSSI_MAX, | 54 | RADIO_RSSI_MAX, |
@@ -57,15 +59,20 @@ enum | |||
57 | 59 | ||
58 | #ifdef HAVE_RDS_CAP | 60 | #ifdef HAVE_RDS_CAP |
59 | /** Readback from the tuner RDS layer **/ | 61 | /** Readback from the tuner RDS layer **/ |
60 | enum | 62 | /* returns needed size if buffer size is inadequate */ |
63 | size_t tuner_get_rds_info(int setting, void *dst, size_t dstsize); | ||
64 | |||
65 | enum RADIO_RDS_INFO | ||
61 | { | 66 | { |
62 | RADIO_RDS_NAME, | 67 | RADIO_RDS_NAME, /* dst: array of char, dstsize: buffer size */ |
63 | RADIO_RDS_TEXT, | 68 | RADIO_RDS_TEXT, /* dst: array of char, dstsize: buffer size */ |
69 | RADIO_RDS_PROGRAM_INFO, /* dst: uint16_t *, dstsize: >= sizeof(uint16_t) */ | ||
70 | RADIO_RDS_CURRENT_TIME, /* dst: time_t *, dstsize: >= sizeof(time_t) */ | ||
64 | 71 | ||
65 | /* Put new general-purpose readback values above this line */ | 72 | /* Put new general-purpose readback values above this line */ |
66 | __RADIO_GET_RDS_INFO_STANDARD_LAST | 73 | __RADIO_GET_RDS_INFO_STANDARD_LAST |
67 | }; | 74 | }; |
68 | #endif | 75 | #endif /* HAVE_RDS_CAP */ |
69 | 76 | ||
70 | /** Tuner regions **/ | 77 | /** Tuner regions **/ |
71 | 78 | ||