From 7a0ddd526c38d2ad6318deb3a10d925086a9a479 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 12 Jul 2014 09:54:42 +0200 Subject: [PATCH] rds-ctl: print RBDS call sign. The PI code encodes a station's call sign for RBDS. Decode it and print the call sign name. Signed-off-by: Hans Verkuil --- utils/rds-ctl/rds-ctl.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp index 7745a8f..e4d2b5d 100644 --- a/utils/rds-ctl/rds-ctl.cpp +++ b/utils/rds-ctl/rds-ctl.cpp @@ -614,6 +614,37 @@ static void print_rds_eon(const struct v4l2_rds_eon_set *eon_set) static void print_rds_pi(const struct v4l2_rds *handle) { + uint16_t pi = handle->pi; + + if (handle->is_rbds) { + char callsign[5] = { 0 }; + uint8_t nibble = handle->pi >> 12; + + if (pi >= 0xafa1 && pi <= 0xafa9) + pi = (pi & 0xf) << 12; + else if (pi > 0xaf11 && pi <= 0xaf1f) + pi = (pi & 0xff) << 8; + else if (pi > 0xaf21 && pi <= 0xafaf) + pi = (pi & 0xff) << 8; + + if (pi > 0xa100 && pi <= 0xa9ff) + pi -= 0x9100; + if (pi > 0x1000 && pi <= 0x54a7) { + pi -= 4096; + callsign[0] = 'K'; + } else if (pi >= 0x54a8 && pi <= 0x994f) { + pi -= 21672; + callsign[0] = 'W'; + } + if (callsign[0]) { + callsign[1] = 'A' + pi / 676; + callsign[2] = 'A' + (pi / 26) % 26; + callsign[3] = 'A' + pi % 26; + printf("\nCall Sign: %s", callsign); + } + if (nibble != 0x0b && nibble != 0x0d && nibble != 0x0e) + return; + } printf("\nArea Coverage: %s", v4l2_rds_get_coverage_str(handle)); } -- 2.7.4