summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted
diff options
context:
space:
mode:
authorLorenzo Miori <memorys60@gmail.com>2012-09-27 11:56:03 +0200
committerThomas Martitz <kugel@rockbox.org>2012-10-06 23:00:36 +0200
commitd2875fc77370509248b638b54969f5ed625d8cac (patch)
tree6ee2e002a5a25f9dd60c7c15f252df2ff1833093 /firmware/target/hosted
parent93023002d6c0f2a5445c1566d74a631ccadeffce (diff)
downloadrockbox-d2875fc77370509248b638b54969f5ed625d8cac.tar.gz
rockbox-d2875fc77370509248b638b54969f5ed625d8cac.zip
This patch adds RDS capability to Samsung YP-R0 target.
Uses register polling method to decide when it's time to decode RDS packets. Change-Id: I1d3cc995ea3350ec7b101438b8f2027130d4a4c9 Reviewed-on: http://gerrit.rockbox.org/320 Reviewed-by: Lorenzo Miori <memorys60@gmail.com> Tested-by: Lorenzo Miori <memorys60@gmail.com> Reviewed-by: Thomas Martitz <kugel@rockbox.org> Tested-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r--firmware/target/hosted/ypr0/radio-ypr0.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/firmware/target/hosted/ypr0/radio-ypr0.c b/firmware/target/hosted/ypr0/radio-ypr0.c
index c3597bd18c..14d56826c1 100644
--- a/firmware/target/hosted/ypr0/radio-ypr0.c
+++ b/firmware/target/hosted/ypr0/radio-ypr0.c
@@ -25,8 +25,12 @@
#include <sys/ioctl.h>
#include "stdint.h"
#include "string.h"
+#include "kernel.h"
#include "radio-ypr0.h"
+#include "rds.h"
+#include "si4700.h"
+#include "power.h"
static int radio_dev = -1;
@@ -63,4 +67,59 @@ int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
(void)address;
sSi4709_i2c_t r = { .size = count, .buf = buf };
return ioctl(radio_dev, IOCTL_SI4709_I2C_READ, &r);
-} \ No newline at end of file
+}
+
+#ifdef HAVE_RDS_CAP
+
+/* Register we are going to poll */
+#define STATUSRSSI 0xA
+#define STATUSRSSI_RDSR (0x1 << 15)
+
+/* Low-level RDS Support */
+static struct event_queue rds_queue;
+static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
+static uint16_t rds_data[4];
+
+enum {
+ Q_POWERUP,
+};
+
+static void NORETURN_ATTR rds_thread(void)
+{
+ /* start up frozen */
+ int timeout = TIMEOUT_BLOCK;
+ struct queue_event ev;
+
+ while (true) {
+ queue_wait_w_tmo(&rds_queue, &ev, timeout);
+ switch (ev.id) {
+ case Q_POWERUP:
+ /* power up: timeout after 1 tick, else block indefinitely */
+ timeout = ev.data ? 1 : TIMEOUT_BLOCK;
+ break;
+ case SYS_TIMEOUT:
+ /* Captures RDS data and processes it */
+ if ((si4709_read_reg(STATUSRSSI) & STATUSRSSI_RDSR) >> 8) {
+ if (si4700_rds_read_raw(rds_data) && rds_process(rds_data))
+ si4700_rds_set_event();
+ }
+ break;
+ }
+ }
+}
+
+/* true after full radio power up, and false before powering down */
+void si4700_rds_powerup(bool on)
+{
+ queue_post(&rds_queue, Q_POWERUP, on);
+}
+
+/* One-time RDS init at startup */
+void si4700_rds_init(void)
+{
+ queue_init(&rds_queue, false);
+ create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds"
+ IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU));
+ rds_init();
+}
+#endif /* HAVE_RDS_CAP */