summaryrefslogtreecommitdiff
path: root/firmware
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
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')
-rw-r--r--firmware/export/config/samsungypr0.h13
-rw-r--r--firmware/target/hosted/ypr0/radio-ypr0.c61
2 files changed, 62 insertions, 12 deletions
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index e97dabcfb2..debe9a3f80 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -18,9 +18,6 @@
18/*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */ 18/*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */
19#define USB_NONE 19#define USB_NONE
20 20
21/* There is only USB charging */
22//#define HAVE_USB_POWER
23
24/* define this if you have a bitmap LCD display */ 21/* define this if you have a bitmap LCD display */
25#define HAVE_LCD_BITMAP 22#define HAVE_LCD_BITMAP
26 23
@@ -28,7 +25,6 @@
28#define HAVE_LCD_COLOR 25#define HAVE_LCD_COLOR
29 26
30/* define this if the LCD needs to be shutdown */ 27/* define this if the LCD needs to be shutdown */
31/* TODO: Our framebuffer must be closed... */
32#define HAVE_LCD_SHUTDOWN 28#define HAVE_LCD_SHUTDOWN
33 29
34/* define this if you want album art for this target */ 30/* define this if you want album art for this target */
@@ -84,7 +80,6 @@
84/* The number of bytes reserved for loadable plugins */ 80/* The number of bytes reserved for loadable plugins */
85#define PLUGIN_BUFFER_SIZE 0x100000 81#define PLUGIN_BUFFER_SIZE 0x100000
86 82
87/* We can do AB-repeat -> we use User key, our hotkey */
88#define AB_REPEAT_ENABLE 83#define AB_REPEAT_ENABLE
89#define ACTION_WPSAB_SINGLE ACTION_WPS_HOTKEY 84#define ACTION_WPSAB_SINGLE ACTION_WPS_HOTKEY
90 85
@@ -93,10 +88,9 @@
93 88
94/* R0 KeyPad configuration for plugins */ 89/* R0 KeyPad configuration for plugins */
95#define CONFIG_KEYPAD SAMSUNG_YPR0_PAD 90#define CONFIG_KEYPAD SAMSUNG_YPR0_PAD
96/* It's better to close /dev/r0Btn at shutdown */
97#define BUTTON_DRIVER_CLOSE 91#define BUTTON_DRIVER_CLOSE
98 92
99/* The YPR0 has a as3534 codec and we use that to control the volume */ 93/* The YPR0 has a as3534 codec */
100#define HAVE_AS3514 94#define HAVE_AS3514
101#define HAVE_AS3543 95#define HAVE_AS3543
102 96
@@ -105,10 +99,7 @@
105#define CONFIG_TUNER SI4700 99#define CONFIG_TUNER SI4700
106#define HAVE_TUNER_PWR_CTRL 100#define HAVE_TUNER_PWR_CTRL
107 101
108/* TODO: next step: enable RDS
109#define HAVE_RDS_CAP 102#define HAVE_RDS_CAP
110#define RDS_ISR_PROCESSING
111*/
112 103
113/* Define this for FM radio input available */ 104/* Define this for FM radio input available */
114#define HAVE_FMRADIO_IN 105#define HAVE_FMRADIO_IN
@@ -154,5 +145,5 @@
154/* Max IMX37 Cpu Frequency */ 145/* Max IMX37 Cpu Frequency */
155/* #define CPUFREQ_MAX CPU_FREQ */ 146/* #define CPUFREQ_MAX CPU_FREQ */
156 147
157/* TODO: my idea is to create a folder in the cramfs [/.rockbox], mounting it by the starter script as the current working directory, so no issues of any type keeping the rockbox folder as in all other players */ 148/* This folder resides in the ReadOnly CRAMFS. It is binded to /mnt/media0/.rockbox */
158#define BOOTDIR "/.rockbox" 149#define BOOTDIR "/.rockbox"
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 @@
25#include <sys/ioctl.h> 25#include <sys/ioctl.h>
26#include "stdint.h" 26#include "stdint.h"
27#include "string.h" 27#include "string.h"
28#include "kernel.h"
28 29
29#include "radio-ypr0.h" 30#include "radio-ypr0.h"
31#include "rds.h"
32#include "si4700.h"
33#include "power.h"
30 34
31static int radio_dev = -1; 35static int radio_dev = -1;
32 36
@@ -63,4 +67,59 @@ int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
63 (void)address; 67 (void)address;
64 sSi4709_i2c_t r = { .size = count, .buf = buf }; 68 sSi4709_i2c_t r = { .size = count, .buf = buf };
65 return ioctl(radio_dev, IOCTL_SI4709_I2C_READ, &r); 69 return ioctl(radio_dev, IOCTL_SI4709_I2C_READ, &r);
66} \ No newline at end of file 70}
71
72#ifdef HAVE_RDS_CAP
73
74/* Register we are going to poll */
75#define STATUSRSSI 0xA
76#define STATUSRSSI_RDSR (0x1 << 15)
77
78/* Low-level RDS Support */
79static struct event_queue rds_queue;
80static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
81static uint16_t rds_data[4];
82
83enum {
84 Q_POWERUP,
85};
86
87static void NORETURN_ATTR rds_thread(void)
88{
89 /* start up frozen */
90 int timeout = TIMEOUT_BLOCK;
91 struct queue_event ev;
92
93 while (true) {
94 queue_wait_w_tmo(&rds_queue, &ev, timeout);
95 switch (ev.id) {
96 case Q_POWERUP:
97 /* power up: timeout after 1 tick, else block indefinitely */
98 timeout = ev.data ? 1 : TIMEOUT_BLOCK;
99 break;
100 case SYS_TIMEOUT:
101 /* Captures RDS data and processes it */
102 if ((si4709_read_reg(STATUSRSSI) & STATUSRSSI_RDSR) >> 8) {
103 if (si4700_rds_read_raw(rds_data) && rds_process(rds_data))
104 si4700_rds_set_event();
105 }
106 break;
107 }
108 }
109}
110
111/* true after full radio power up, and false before powering down */
112void si4700_rds_powerup(bool on)
113{
114 queue_post(&rds_queue, Q_POWERUP, on);
115}
116
117/* One-time RDS init at startup */
118void si4700_rds_init(void)
119{
120 queue_init(&rds_queue, false);
121 create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds"
122 IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU));
123 rds_init();
124}
125#endif /* HAVE_RDS_CAP */