summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-02-11 23:16:39 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-02-11 23:16:39 -0500
commit523ef4edbdccf8198fbb7787afba2fe3f46f1ca8 (patch)
tree3238ca1502c92ce2078ff58a6f2a2589eaa68a95
parentfc9695eb47732e1c189e2f033dbd55e5c346e8c4 (diff)
downloadrockbox-523ef4e.tar.gz
rockbox-523ef4e.tar.bz2
rockbox-523ef4e.zip
Fix warnings and errors from fc9695e
* fmradio.c needs an implementation of tuner_get_rds_info() for the sim (kill all the sims). * Some macro bitflags shouldn't be seen unless HAVE_RDS_CAP is defined. Change-Id: Idd00c94ca2fc43cf32f9223aa4530d5a02fb3454
-rw-r--r--firmware/drivers/tuner/si4700.c2
-rw-r--r--uisimulator/common/fmradio.c56
2 files changed, 45 insertions, 13 deletions
diff --git a/firmware/drivers/tuner/si4700.c b/firmware/drivers/tuner/si4700.c
index c7d942f293..af5795a83f 100644
--- a/firmware/drivers/tuner/si4700.c
+++ b/firmware/drivers/tuner/si4700.c
@@ -28,7 +28,9 @@
#include "tuner.h" /* tuner abstraction interface */
#include "fmradio.h"
#include "fmradio_i2c.h" /* physical interface driver */
+#ifdef HAVE_RDS_CAP
#include "rds.h"
+#endif
#if defined(SANSA_CLIP) || defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) \
|| defined(SANSA_FUZEPLUS)
diff --git a/uisimulator/common/fmradio.c b/uisimulator/common/fmradio.c
index 6f6b0f914f..a18db819f2 100644
--- a/uisimulator/common/fmradio.c
+++ b/uisimulator/common/fmradio.c
@@ -23,6 +23,11 @@
#include "config.h"
#include "debug.h"
#include "tuner.h"
+#ifdef HAVE_RDS_CAP
+#include <strlcpy.h>
+#include "system.h"
+#include "rds.h"
+#endif
#if CONFIG_TUNER
@@ -124,21 +129,46 @@ bool tuner_power(bool status)
}
#ifdef HAVE_RDS_CAP
-char* tuner_get_rds_info(int setting)
+size_t tuner_get_rds_info(int setting, void *dst, size_t dstsize)
{
- char *text = NULL;
-
- switch(setting)
+ /* TODO: integrate this into tuner_get/set */
+ static const unsigned char info_id_tbl[] =
{
- case RADIO_RDS_NAME:
- text = "Rockbox Radio";
- break;
+ [RADIO_RDS_NAME] = RDS_INFO_PS,
+ [RADIO_RDS_TEXT] = RDS_INFO_RT,
+ [RADIO_RDS_PROGRAM_INFO] = RDS_INFO_PI,
+ [RADIO_RDS_CURRENT_TIME] = RDS_INFO_CT,
+ };
- case RADIO_RDS_TEXT:
- text = "http://www.rockbox.org" ;
- break;
+ if ((unsigned int)setting >= ARRAYLEN(info_id_tbl))
+ return 0;
+
+ switch (info_id_tbl[setting])
+ {
+ case RDS_INFO_PI:
+ if (dstsize >= sizeof (uint16_t)) {
+ *(uint16_t *)dst = 0;
+ }
+ dstsize = sizeof (uint16_t);
+ break;
+ case RDS_INFO_PS:
+ dstsize = strlcpy(dst, "Rockbox Radio", dstsize);
+ break;
+ case RDS_INFO_RT:
+ dstsize = strlcpy(dst, "http://www.rockbox.org", dstsize);
+ break;
+ case RDS_INFO_CT:
+ if (dstsize >= sizeof (time_t)) {
+ *(time_t *)dst = 0;
+ }
+ dstsize = sizeof (time_t);
+ break;
+
+ default:
+ dstsize = 0;
}
- return text;
+
+ return dstsize;
}
-#endif
-#endif
+#endif /* HAVE_RDS_CAP */
+#endif /* CONFIG_TUNER */