diff options
-rw-r--r-- | fmrxd.h | 6 | ||||
-rw-r--r-- | rds.c | 4 | ||||
-rw-r--r-- | server.c | 2 | ||||
-rw-r--r-- | signal.c | 10 | ||||
-rw-r--r-- | tuner.c | 2 |
5 files changed, 17 insertions, 7 deletions
@@ -38,8 +38,10 @@ #define TUNER_DEVICE_ID 0 /** Enable the wl1273 N950/N9 RDS decoding workarounds. */ -#define CRAPPY_WL1273_RDS 1 +#define WORKAROUND_BAD_WL1273_RDS 1 +/** Enable the wl1273 N950/N9 signal level workarounds. */ +#define WORKAROUND_BAD_WL1273_SIGNAL 1 /** Poll the signal level every this many seconds. */ #define SIGNAL_POLL_INTERVAL 10 /** After tuning, refresh the signal level once after this many miliseconds. */ @@ -80,7 +82,7 @@ bool configure_capture(bool on); bool configure_tuner(bool on); extern int tuner_fd; bool tuner_set_frequency(double mhz); -uint16_t tuner_get_signal(); +int32_t tuner_get_signal(); bool tuner_search(bool forward); /* rds.c -- RDS decoder */ @@ -25,7 +25,7 @@ #include "fmrxd.h" -#if CRAPPY_WL1273_RDS +#if WORKAROUND_BAD_WL1273_RDS #define WL1273_RDS_BLOCK_A 0 #define WL1273_RDS_BLOCK_B 1 #define WL1273_RDS_BLOCK_C 2 @@ -190,7 +190,7 @@ static gboolean rds_callback(GIOChannel *source, GIOCondition condition, int block; bool error; -#if CRAPPY_WL1273_RDS +#if WORKAROUND_BAD_WL1273_RDS block = rds.block & WL1273_RDS_BLOCK_MASK; // The following is, in a "more" readable way, swapping 3 and 4. switch (block) { @@ -73,7 +73,7 @@ static const char * introspect_data = { " <signal name=\"Stopped\">\n" " </signal>\n" " <signal name=\"SignalLevelChanged\">\n" - " <arg type=\"q\" name=\"signal\" />\n" + " <arg type=\"q\" name=\"level\" />\n" " </signal>\n" " <signal name=\"PiReceived\">\n" " <arg type=\"q\" name=\"pi\" />\n" @@ -27,7 +27,15 @@ static uint16_t last_signal_level = 0; static void signal_update() { - uint16_t new_signal_level = tuner_get_signal(); + uint16_t new_signal_level; +#if WORKAROUND_BAD_WL1273_SIGNAL + /* rssi is a value from -128 to +127. */ + new_signal_level = (tuner_get_signal() + 128) * 257; +#else + /* rssi is a value from 0 to 65535. */ + new_signal_level = tuner_get_signal(); +#endif + if (new_signal_level != last_signal_level) { server_notify_signal(new_signal_level); last_signal_level = new_signal_level; @@ -174,7 +174,7 @@ bool tuner_set_frequency(double mhz) return false; } -uint16_t tuner_get_signal() +int32_t tuner_get_signal() { struct v4l2_tuner t_tuner = { .index = TUNER_DEVICE_ID |