[RFC PATCHv2 2/3] rds-ctl: support RDS-EON and TMC-tuning info
Signed-off-by: Konke Radlow korad...@gmail.com rds-ctl.cpp: added functionality to print RDS-EON information Signed-off-by: Konke Radlow korad...@gmail.com rds-ctl.cpp: added functionality to print RDS-TMC tuning information Signed-off-by: Konke Radlow korad...@gmail.com rds-ctl.cpp: clarify option description, change trigger condition for printing TMC Tuning information Signed-off-by: Konke Radlow korad...@gmail.com --- utils/rds-ctl/rds-ctl.cpp | 59 +++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp index 191cfee..d894ec1 100644 --- a/utils/rds-ctl/rds-ctl.cpp +++ b/utils/rds-ctl/rds-ctl.cpp @@ -130,7 +130,7 @@ static void usage_hint(void) static void usage_common(void) { printf(\nGeneral/Common options:\n ---all display all information available\n +--all display all device information available\n -D, --info show driver info [VIDIOC_QUERYCAP]\n -d, --device=dev use device dev\n if dev is a single digit, then /dev/radiodev is used\n @@ -172,7 +172,7 @@ static void usage_rds(void) default: 5000 ms\n --print-block prints all valid RDS fields, whenever a value is updated\n instead of printing only updated values\n ---tmc enables decoding of TMC (Traffic Message Channel) data\n +--tmc print information about TMC (Traffic Message Channel) messages\n --silent only set the result code, do not print any messages\n --verbose turn on verbose mode - every received RDS group\n will be printed\n @@ -517,6 +517,30 @@ static void print_rds_tmc(const struct v4l2_rds *handle, uint32_t updated_fields } } +static void print_rds_tmc_tuning(const struct v4l2_rds *handle, uint32_t updated_fields) +{ + const struct v4l2_tmc_tuning *tuning = handle-tmc.tuning; + const struct v4l2_tmc_station *station; + + if (updated_fields V4L2_RDS_TMC_TUNING) { + printf(\nTMC Service provider: %s, %u alternative stations\n, handle-tmc.spn, tuning-station_cnt); + for (int i = 0; i tuning-station_cnt; i++) { + station = tuning-station[i]; + printf(PI(ON %02u) = %04x, AFs: %u, mapped AFs: %u \n, i, station-pi, + station-afi.af_size, station-afi.mapped_af_size); + for (int j = 0; j station-afi.af_size; j++) + printf(AF%02d: %.1fMHz\n, j, station-afi.af[j] / 100.0); + for (int k = 0; k station-afi.mapped_af_size; k++) + printf(m_AF%02d: %.1fMHz = %.1fMHz\n, k, + station-afi.mapped_af_tuning[k] / 100.0, + station-afi.mapped_af[k] / 100.0); + if (station-ltn != 0 || station-msg != 0 || station- sid != 0) + printf(ltn: %02x, msg: %02x, sid: %02x\n, station-ltn, + station-msg, station-sid); + } + } +} + static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) { printf(\n\nRDS Statistics: \n); @@ -557,6 +581,33 @@ static void print_rds_af(const struct v4l2_rds_af_set *af_set) } } +static void print_rds_eon(const struct v4l2_rds_eon_set *eon_set) +{ + int counter = 0; + + printf(\n\nEnhanced Other Network information: %u channels, eon_set-size); + for (int i = 0; i eon_set-size; i++, counter++) { + if (eon_set-eon[i].valid_fields V4L2_RDS_PI) + printf(\nPI(ON %02i) = %04x, i, eon_set-eon[i].pi); + if (eon_set-eon[i].valid_fields V4L2_RDS_PS) + printf(\nPS(ON %02i) = %s, i, eon_set-eon[i].ps); + if (eon_set-eon[i].valid_fields V4L2_RDS_PTY) + printf(\nPTY(ON %02i) = %0u, i, eon_set-eon[i].pty); + if (eon_set-eon[i].valid_fields V4L2_RDS_LSF) + printf(\nLSF(ON %02i) = %0u, i, eon_set-eon[i].lsf); + if (eon_set-eon[i].valid_fields V4L2_RDS_AF) + printf(\nPTY(ON %02i) = %0u, i, eon_set-eon[i].pty); + if (eon_set-eon[i].valid_fields V4L2_RDS_TP) + printf(\nTP(ON %02i): %s, i, eon_set-eon[i].tp? yes:no); + if (eon_set-eon[i].valid_fields V4L2_RDS_TA) + printf(\nTA(ON %02i): %s, i, eon_set-eon[i].tp? yes:no
[RFC PATCHv2 0/3] libv4l2rds: add support for RDS-EON and TMC-tuning decoding
This patch series is based on the commments to: [RFC PATCH 0/4] libv4l2rds: support for decoding RDS tuning information [RFC PATCH 1/4] libv4l2rds: added support to decode RDS-EON information [RFC PATCH 2/4] rds-ctl.cpp: added functionality to print RDS-EON information [RFC PATCH 3/4] libv4l2rds: added support to decode RDS-TMC tuning information [RFC PATCH 4/4] rds-ctl.cpp: added functionality to print RDS-TMC tuning information The proposed changes have been integrated and the patches (1, 3) and (2, 4) have been merged into one unit. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCHv2 3/3] libv4l2rds.c: moving functions to get rid of declarations Signed-off-by: Konke Radlow korad...@gmail.com
Signed-off-by: Konke Radlow korad...@gmail.com --- lib/libv4l2rds/libv4l2rds.c | 243 +-- 1 file changed, 120 insertions(+), 123 deletions(-) diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c index 28b78ce..333bf95 100644 --- a/lib/libv4l2rds/libv4l2rds.c +++ b/lib/libv4l2rds/libv4l2rds.c @@ -92,11 +92,6 @@ enum rds_state { RDS_C_RECEIVED, }; -/* function declarations to prevent the need to move large code blocks */ -static int rds_add_tmc_station(struct rds_private_state *priv_state, uint16_t pi); -static uint32_t rds_decode_af(uint8_t af, bool is_vhf); -static bool rds_add_tmc_af(struct rds_private_state *priv_state); - static inline uint8_t set_bit(uint8_t input, uint8_t bitmask, bool bitvalue) { return bitvalue ? input | bitmask : input ~bitmask; @@ -201,6 +196,29 @@ static void rds_decode_d(struct rds_private_state *priv_state, struct v4l2_rds_d grp-data_d_lsb = rds_data-lsb; } +/* decodes the RDS radio frequency representation into Hz + * @af: 8-bit AF value as transmitted in RDS groups + * @is_vhf: boolean value defining which conversion table to use + * @return: frequency in Hz, 0 in case of wrong input values */ +static uint32_t rds_decode_af(uint8_t af, bool is_vhf) { + uint32_t freq = 0; + + /* AF = 0 = not to be used +* AF = 205 = special meanings */ + if (af == 0 || af = 205) + return 0; + + /* calculate the AF values in HZ */ + if (is_vhf) + freq = 8750 + af * 10; + else if (freq = 15) + freq = 152000 + af * 9000; + else + freq = 531000 + af * 9000; + + return freq; +} + /* compare two rds-groups for equality */ /* used for decoding RDS-TMC, which has the requirement that the same group * is at least received twice before it is accepted */ @@ -224,6 +242,103 @@ static bool rds_compare_group(const struct v4l2_rds_group *a, return true; } +/* checks if an entry for the given PI already exists and returns the index + * of that entry if so. Else it adds a new entry to the TMC-Tuning table and returns + * the index of the new field */ +static int rds_add_tmc_station(struct rds_private_state *priv_state, uint16_t pi) +{ + struct v4l2_tmc_tuning *tuning = priv_state-handle.tmc.tuning; + uint8_t index = tuning-index; + uint8_t size = tuning-station_cnt; + + /* check if there's an entry for the given PI key */ + for (int i = 0; i tuning-station_cnt; i++) { + if (tuning-station[i].pi == pi) { + return i; + } + } + /* if the the maximum table size is reached, overwrite old +* entries, starting at the oldest one = 0 */ + tuning-station[index].pi = pi; + tuning-index = (index+1 MAX_TMC_ALT_STATIONS) ? (index+1) : 0; + tuning-station_cnt = (size+1 = MAX_TMC_ALT_STATIONS) ? (size+1) : MAX_TMC_ALT_STATIONS; + return index; +} + +/* tries to add new AFs to the relevant entry in the list of RDS-TMC providers */ +static bool rds_add_tmc_af(struct rds_private_state *priv_state) +{ + struct v4l2_rds_group *grp = priv_state-rds_group; + struct v4l2_tmc_alt_freq *afi; + uint16_t pi_on = grp-data_d_msb 8 | grp-data_d_lsb; + uint8_t variant = grp-data_b_lsb 0x0f; + uint8_t station_index = rds_add_tmc_station(priv_state, pi_on); + uint8_t af_index; + uint8_t mapped_af_index; + uint32_t freq_a = rds_decode_af(grp-data_c_msb, true); + uint32_t freq_b = rds_decode_af(grp-data_c_lsb, true); + + afi = priv_state-handle.tmc.tuning.station[station_index].afi; + af_index = afi-af_index; + mapped_af_index = afi-mapped_af_index; + + /* specific frequencies */ + if (variant == 6) { + /* compare the new AFs to the stored ones, reset them to 0 if the AFs are +* already known */ + for (int i = 0; i afi-af_size; i++) { + freq_a = (freq_a == afi-af[i]) ? 0 : freq_a; + freq_b = (freq_b == afi-af[i]) ? 0 : freq_b; + } + /* return early if there is nothing to do */ + if (freq_a == 0 freq_b == 0) + return false; + + /* add the new AFs if they were previously unknown */ + if (freq_a != 0) { + afi-af[af_index] = freq_a; + af_index = (af_index+1 MAX_TMC_AF_CNT) ? af_index+1 : 0; + afi-af_size++; + } + if (freq_b != 0) { + afi-af[af_index] = freq_b; + af_index = (af_index+1 MAX_TMC_AF_CNT) ? af_index+1 : 0; + afi-af_size++; + } + /* update the information in the handle */ + afi-af_index = af_index
[RFC PATCHv2 1/3] libv4l2rds: support RDS-EON and TMC-tuning info
Signed-off-by: Konke Radlow korad...@gmail.com libv4l2rds: added support to decode RDS-EON information Signed-off-by: Konke Radlow korad...@gmail.com libv4l2rds: added support to decode RDS-TMC tuning information Signed-off-by: Konke Radlow korad...@gmail.com libv4l2rds.c: fixing compiler warnings due to missing pointer dereferencing and implementing changes proposed in RFC replies (RDS-EON patch) Signed-off-by: Konke Radlow korad...@gmail.com libv4l2rds: implementing changes proposed in RFC replies (TMC-Tuning patch) Signed-off-by: Konke Radlow korad...@gmail.com --- lib/include/libv4l2rds.h| 79 +- lib/libv4l2rds/libv4l2rds.c | 363 --- 2 files changed, 417 insertions(+), 25 deletions(-) diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h index 6a6c7f3..e1078de 100644 --- a/lib/include/libv4l2rds.h +++ b/lib/include/libv4l2rds.h @@ -37,7 +37,7 @@ extern C { #endif /* used to define the current version (version field) of the v4l2_rds struct */ -#define V4L2_RDS_VERSION (1) +#define V4L2_RDS_VERSION (2) /* Constants used to define the size of arrays used to store RDS information */ #define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these @@ -50,6 +50,16 @@ extern C { * Additional data is limited to 112 bit, and the smallest * optional tuple has a size of 4 bit (4 bit identifier + * 0 bits of data) */ +#define MAX_TMC_ALT_STATIONS 32 /* defined by ISO 14819-1:2003, 7.5.3.3 */ +#define MAX_TMC_AF_CNT 4 /* limit for the numbers of AFs stored per alternative TMC + * station. This value is not defined by the standard, but based on observation + * of real-world RDS-TMC streams. The maximum encountered number of AFs per + * station during testing was 2 */ +#define MAX_EON_CNT 20 /* Maximal number of entries in the EON table (for storing + * information about other radio stations, broadcasted by the current station). + * This value is not defined by the standard, but based on observation + * of real-world RDS-TMC streams. EON doesn't seem to be a widely used feature + * and the maximum number of EON encountered during testing was 8 */ /* Define Constants for the possible types of RDS information * used to address the relevant bit in the valid_fields bitmask */ @@ -69,7 +79,10 @@ extern C { #define V4L2_RDS_LC0x2000 /* Language Code */ #define V4L2_RDS_TMC_SG0x4000 /* RDS-TMC single group */ #define V4L2_RDS_TMC_MG0x8000 /* RDS-TMC multi group */ -#define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ +#define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ +#define V4L2_RDS_EON 0x2 /* Enhanced Other Network Info */ +#define V4L2_RDS_LSF 0x4 /* Linkage information */ +#define V4L2_RDS_TMC_TUNING0x8 /* RDS-TMC tuning information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */ @@ -84,9 +97,10 @@ extern C { #define V4L2_RDS_FLAG_STATIC_PTY 0x08 /* TMC related codes - * used to extract TMC fields from RDS groups */ -#define V4L2_TMC_TUNING_INFO 0x08 -#define V4L2_TMC_SINGLE_GROUP 0x04 + * used to extract TMC fields from RDS-TMC groups + * see ISO 14819-1:2003, Figure 2 - RDS-TMC single-grp full message structure */ +#define V4L2_TMC_TUNING_INFO 0x10/* Bit 4 indicates Tuning Info / User msg */ +#define V4L2_TMC_SINGLE_GROUP 0x08/* Bit 3 indicates Single / Multi-group msg */ /* struct to encapsulate one complete RDS group */ /* This structure is used internally to store data until a complete RDS @@ -149,6 +163,57 @@ struct v4l2_rds_af_set { uint32_t af[MAX_AF_CNT];/* AFs defined in Hz */ }; +/* struct to encapsulate one entry in the EON table (Enhanced Other Network) */ +struct v4l2_rds_eon { + uint32_t valid_fields; + uint16_t pi; + uint8_t ps[9]; + uint8_t pty; + bool ta; + bool tp; + uint16_t lsf; /* Linkage Set Number */ + struct v4l2_rds_af_set af; +}; + +/* struct to encapsulate a table of EON information */ +struct v4l2_rds_eon_set { + uint8_t size; /* size of the table */ + uint8_t index; /* current position in the table */ + struct v4l2_rds_eon eon[MAX_EON_CNT]; /* Information about other +* radio channels */ +}; + +/* struct to encapsulate alternative frequencies (AFs) for RDS-TMC stations. + * AFs listed in af[] can be used unconditionally. + * AFs listed in mapped_af[n] should only be used if the current + * tuner frequency matches the value
Re: [RFC PATCH 3/4] libv4l2rds: added support to decode RDS-TMC tuning information
Hi Hans, Thank you for your comments, they're very appreciated as always :) I will integrate the proposals and submit an updated version towards the end of this week. To my best knowledge I would say that the functionality of RDS/TMC as defined by the standards is completely implemented now. And I agree that human readable output for the TMC messages would be nice to have, but I'm quite busy with my thesis atm and will not make any promises ;) Cheers, Konke On Fri, May 10, 2013 at 12:46 PM, Hans Verkuil hverk...@xs4all.nl wrote: On Tue May 7 2013 18:24:22 Konke Radlow wrote: Signed-off-by: Konke Radlow korad...@gmail.com --- lib/include/libv4l2rds.h| 39 +++ lib/libv4l2rds/libv4l2rds.c | 159 +-- 2 files changed, 194 insertions(+), 4 deletions(-) diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h index 62b28bc..45dc2d1 100644 --- a/lib/include/libv4l2rds.h +++ b/lib/include/libv4l2rds.h @@ -50,6 +50,10 @@ extern C { * Additional data is limited to 112 bit, and the smallest * optional tuple has a size of 4 bit (4 bit identifier + * 0 bits of data) */ +#define MAX_TMC_ALT_STATIONS 32 /* defined by ISO 14819-1:2003, 7.5.3.3 */ +#define MAX_TMC_AF_CNT 4 /* limit for the numbers of AFs stored per alternative TMC + * station. This value is not defined by the standard, but based on observation + * of real-world RDS-TMC streams */ Could you clarify this a bit more? E.g. what is the maximum number of AFs you have seen in practice? #define MAX_EON_CNT 20 /* Maximal number of entries in the EON table (for storing * information about other radio stations, broadcasted * by the current station) */ @@ -75,6 +79,7 @@ extern C { #define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ #define V4L2_RDS_EON 0x2 /* Enhanced Other Network Info */ #define V4L2_RDS_LSF 0x4 /* Linkage information */ +#define V4L2_RDS_TMC_TUNING 0x8 /* RDS-TMC tuning information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */ @@ -175,6 +180,37 @@ struct v4l2_rds_eon_set { * radio channels */ }; +/* struct to encapsulate alternative frequencies (AFs) for RDS-TMC stations. + * AFs listed in af[] can be used unconditionally. + * AFs listed in mapped_af[n] should only be used if the current + * tuner frequency matches the value in mapped_af_tuning[n] */ +struct v4l2_tmc_alt_freq { + uint8_t af_size;/* number of known AFs */ + uint8_t af_index; + uint8_t mapped_af_size; /* number of mapped AFs */ + uint8_t mapped_af_index; + uint32_t af[MAX_TMC_AF_CNT];/* AFs defined in Hz */ + uint32_t mapped_af[MAX_TMC_AF_CNT]; /* mapped AFs defined in Hz */ + uint32_t mapped_af_tuning[MAX_TMC_AF_CNT]; /* mapped AFs defined in Hz */ +}; + +/* struct to encapsulate information about stations carrying RDS-TMC services */ +struct v4l2_tmc_station { + uint16_t pi; + uint8_t ltn;/* database-ID of ON */ + uint8_t msg;/* msg parameters of ON */ + uint8_t sid;/* service-ID of ON */ + struct v4l2_tmc_alt_freq afi; +}; + +/* struct to encapsulate tuning information for TMC */ +struct v4l2_tmc_tuning { + uint8_t station_cnt;/* number of announced alternative stations */ + uint8_t index; + struct v4l2_tmc_station station[MAX_TMC_ALT_STATIONS]; /* information + * about other stations carrying the same RDS-TMC service */ +}; + /* struct to encapsulate an additional data field in a TMC message */ struct v4l2_tmc_additional { uint8_t label; @@ -225,6 +261,9 @@ struct v4l2_rds_tmc { uint8_t t_d;/* delay time (only if mode = enhanced */ uint8_t spn[9]; /* service provider name */ struct v4l2_rds_tmc_msg tmc_msg; + + /* tuning information for alternative service providers */ + struct v4l2_tmc_tuning tuning; }; /* struct to encapsulate state and RDS information for current decoding process */ diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c index 3a90a3b..3995c3d 100644 --- a/lib/libv4l2rds/libv4l2rds.c +++ b/lib/libv4l2rds/libv4l2rds.c @@ -93,7 +93,9 @@ enum rds_state { }; /* function declarations to prevent the need to move large code blocks */ +static int rds_add_tmc_station(struct rds_private_state *priv_state, uint16_t pi); static uint32_t rds_decode_af(uint8_t af, bool is_vhf); +static bool rds_add_tmc_af(struct rds_private_state *priv_state); Same comment as previously: just have a separate
[RFC PATCH 0/4] libv4l2rds: support for decoding RDS tuning information
This set of patches adds support to decode information about other networks and radio stations which can submitted as a part of the RDS and RDS-TMC data stream. RDS-EON: Enhanced Other Network information that can be used to update the information stored in the receiver about programme service other than the one received. Alternative frequencies, the PS name, Traffic Programme and Traffic Announcement identification as well as Programme Type and Programme Item Number information can be transmitted for each other service. RDS-TMC-Tuning: Detailed information about other stations that carry the same RDS-TMC service that can be used by terminals to tune directly to a new station at boundaries of a transmitter's coverage. -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 1/4] libv4l2rds: added support to decode RDS-EON information
Signed-off-by: Konke Radlow korad...@gmail.com --- lib/include/libv4l2rds.h| 35 +++- lib/libv4l2rds/libv4l2rds.c | 190 --- 2 files changed, 208 insertions(+), 17 deletions(-) diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h index 6a6c7f3..62b28bc 100644 --- a/lib/include/libv4l2rds.h +++ b/lib/include/libv4l2rds.h @@ -50,6 +50,9 @@ extern C { * Additional data is limited to 112 bit, and the smallest * optional tuple has a size of 4 bit (4 bit identifier + * 0 bits of data) */ +#define MAX_EON_CNT 20 /* Maximal number of entries in the EON table (for storing + * information about other radio stations, broadcasted + * by the current station) */ /* Define Constants for the possible types of RDS information * used to address the relevant bit in the valid_fields bitmask */ @@ -69,7 +72,9 @@ extern C { #define V4L2_RDS_LC0x2000 /* Language Code */ #define V4L2_RDS_TMC_SG0x4000 /* RDS-TMC single group */ #define V4L2_RDS_TMC_MG0x8000 /* RDS-TMC multi group */ -#define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ +#define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ +#define V4L2_RDS_EON 0x2 /* Enhanced Other Network Info */ +#define V4L2_RDS_LSF 0x4 /* Linkage information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */ @@ -84,9 +89,10 @@ extern C { #define V4L2_RDS_FLAG_STATIC_PTY 0x08 /* TMC related codes - * used to extract TMC fields from RDS groups */ -#define V4L2_TMC_TUNING_INFO 0x08 -#define V4L2_TMC_SINGLE_GROUP 0x04 + * used to extract TMC fields from RDS-TMC groups + * see ISO 14819-1:2003, Figure 2 - RDS-TMC single-grp full message structure */ +#define V4L2_TMC_TUNING_INFO 0x10/* Bit 4 indicates Tuning Info / User msg */ +#define V4L2_TMC_SINGLE_GROUP 0x08/* Bit 3 indicates Single / Multi-group msg */ /* struct to encapsulate one complete RDS group */ /* This structure is used internally to store data until a complete RDS @@ -149,6 +155,26 @@ struct v4l2_rds_af_set { uint32_t af[MAX_AF_CNT];/* AFs defined in Hz */ }; +/* struct to encapsulate one entry in the EON table (Enhanced Other Network) */ +struct v4l2_rds_eon { + uint32_t valid_fields; + uint16_t pi; + uint8_t ps[9]; + uint8_t pty; + bool ta; + bool tp; + uint16_t lsf; /* Linkage Set Number */ + struct v4l2_rds_af_set af; +}; + +/* struct to encapsulate a table of EON information */ +struct v4l2_rds_eon_set { + uint8_t size; /* size of the table */ + uint8_t index; /* current position in the table */ + struct v4l2_rds_eon eon[MAX_EON_CNT]; /* Information about other +* radio channels */ +}; + /* struct to encapsulate an additional data field in a TMC message */ struct v4l2_tmc_additional { uint8_t label; @@ -236,6 +262,7 @@ struct v4l2_rds { struct v4l2_rds_statistics rds_statistics; struct v4l2_rds_oda_set rds_oda;/* Open Data Services */ struct v4l2_rds_af_set rds_af; /* Alternative Frequencies */ + struct v4l2_rds_eon_set rds_eon;/* EON information */ struct v4l2_rds_tmc tmc;/* TMC information */ }; diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c index 2918061..3a90a3b 100644 --- a/lib/libv4l2rds/libv4l2rds.c +++ b/lib/libv4l2rds/libv4l2rds.c @@ -92,6 +92,9 @@ enum rds_state { RDS_C_RECEIVED, }; +/* function declarations to prevent the need to move large code blocks */ +static uint32_t rds_decode_af(uint8_t af, bool is_vhf); + static inline uint8_t set_bit(uint8_t input, uint8_t bitmask, bool bitvalue) { return bitvalue ? input | bitmask : input ~bitmask; @@ -455,20 +458,11 @@ static bool rds_add_oda(struct rds_private_state *priv_state, struct v4l2_rds_od /* add a new AF to the list, if it doesn't exist yet */ static bool rds_add_af_to_list(struct v4l2_rds_af_set *af_set, uint8_t af, bool is_vhf) { - uint32_t freq = 0; - - /* AF0 - Not to be used */ - if (af == 0) + /* convert the frequency to Hz, skip on errors */ + uint32_t freq = rds_decode_af(af, is_vhf); + if (freq == 0) return false; - /* calculate the AF values in HZ */ - if (is_vhf) - freq = 8750 + af * 10; - else if (freq = 15) - freq = 152000 + af * 9000; - else - freq = 531000 + af * 9000; - /* prevent buffer overflows */ if (af_set-size = MAX_AF_CNT || af_set-size = af_set-announced_af
[RFC PATCH 2/4] rds-ctl.cpp: added functionality to print RDS-EON information
Signed-off-by: Konke Radlow korad...@gmail.com --- utils/rds-ctl/rds-ctl.cpp | 29 + 1 file changed, 29 insertions(+) diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp index de76d9f..51536cf 100644 --- a/utils/rds-ctl/rds-ctl.cpp +++ b/utils/rds-ctl/rds-ctl.cpp @@ -550,6 +550,33 @@ static void print_rds_af(const struct v4l2_rds_af_set *af_set) } } +static void print_rds_eon(const struct v4l2_rds_eon_set *eon_set) +{ + int counter = 0; + + printf(\n\nEnhanced Other Network information: %u channels, eon_set-size); + for (int i = 0; i eon_set-size; i++, counter++) { + if (eon_set-eon[i].valid_fields V4L2_RDS_PI) + printf(\nPI(ON %02i) = %04x, i, eon_set-eon[i].pi); + if (eon_set-eon[i].valid_fields V4L2_RDS_PS) + printf(\nPS(ON %02i) = %s, i, eon_set-eon[i].ps); + if (eon_set-eon[i].valid_fields V4L2_RDS_PTY) + printf(\nPTY(ON %02i) = %0u, i, eon_set-eon[i].pty); + if (eon_set-eon[i].valid_fields V4L2_RDS_LSF) + printf(\nLSF(ON %02i) = %0u, i, eon_set-eon[i].lsf); + if (eon_set-eon[i].valid_fields V4L2_RDS_AF) + printf(\nPTY(ON %02i) = %0u, i, eon_set-eon[i].pty); + if (eon_set-eon[i].valid_fields V4L2_RDS_TP) + printf(\nTP(ON %02i): %s ,i ,eon_set-eon[i].tp? yes:no); + if (eon_set-eon[i].valid_fields V4L2_RDS_TA) + printf(\nTA(ON %02i): %s,i ,eon_set-eon[i].tp? yes:no); + if (eon_set-eon[i].valid_fields V4L2_RDS_AF) { + printf(\nAF(ON %02i): size=%i, i, eon_set-eon[i].af.size); + print_rds_af((eon_set-eon[i].af)); + } + } +} + static void print_rds_pi(const struct v4l2_rds *handle) { printf(\nArea Coverage: %s, v4l2_rds_get_coverage_str(handle)); @@ -662,6 +689,8 @@ static void read_rds_from_fd(const int fd) /* try to receive and decode RDS data */ read_rds(rds_handle, fd, params.wait_limit); + if (rds_handle-valid_fields V4L2_RDS_EON) + print_rds_eon(rds_handle-rds_eon); print_rds_statistics(rds_handle-rds_statistics); v4l2_rds_destroy(rds_handle); -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 3/4] libv4l2rds: added support to decode RDS-TMC tuning information
Signed-off-by: Konke Radlow korad...@gmail.com --- lib/include/libv4l2rds.h| 39 +++ lib/libv4l2rds/libv4l2rds.c | 159 +-- 2 files changed, 194 insertions(+), 4 deletions(-) diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h index 62b28bc..45dc2d1 100644 --- a/lib/include/libv4l2rds.h +++ b/lib/include/libv4l2rds.h @@ -50,6 +50,10 @@ extern C { * Additional data is limited to 112 bit, and the smallest * optional tuple has a size of 4 bit (4 bit identifier + * 0 bits of data) */ +#define MAX_TMC_ALT_STATIONS 32 /* defined by ISO 14819-1:2003, 7.5.3.3 */ +#define MAX_TMC_AF_CNT 4 /* limit for the numbers of AFs stored per alternative TMC + * station. This value is not defined by the standard, but based on observation + * of real-world RDS-TMC streams */ #define MAX_EON_CNT 20 /* Maximal number of entries in the EON table (for storing * information about other radio stations, broadcasted * by the current station) */ @@ -75,6 +79,7 @@ extern C { #define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ #define V4L2_RDS_EON 0x2 /* Enhanced Other Network Info */ #define V4L2_RDS_LSF 0x4 /* Linkage information */ +#define V4L2_RDS_TMC_TUNING0x8 /* RDS-TMC tuning information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */ @@ -175,6 +180,37 @@ struct v4l2_rds_eon_set { * radio channels */ }; +/* struct to encapsulate alternative frequencies (AFs) for RDS-TMC stations. + * AFs listed in af[] can be used unconditionally. + * AFs listed in mapped_af[n] should only be used if the current + * tuner frequency matches the value in mapped_af_tuning[n] */ +struct v4l2_tmc_alt_freq { + uint8_t af_size;/* number of known AFs */ + uint8_t af_index; + uint8_t mapped_af_size; /* number of mapped AFs */ + uint8_t mapped_af_index; + uint32_t af[MAX_TMC_AF_CNT];/* AFs defined in Hz */ + uint32_t mapped_af[MAX_TMC_AF_CNT]; /* mapped AFs defined in Hz */ + uint32_t mapped_af_tuning[MAX_TMC_AF_CNT]; /* mapped AFs defined in Hz */ +}; + +/* struct to encapsulate information about stations carrying RDS-TMC services */ +struct v4l2_tmc_station { + uint16_t pi; + uint8_t ltn;/* database-ID of ON */ + uint8_t msg;/* msg parameters of ON */ + uint8_t sid;/* service-ID of ON */ + struct v4l2_tmc_alt_freq afi; +}; + +/* struct to encapsulate tuning information for TMC */ +struct v4l2_tmc_tuning { + uint8_t station_cnt;/* number of announced alternative stations */ + uint8_t index; + struct v4l2_tmc_station station[MAX_TMC_ALT_STATIONS]; /* information + * about other stations carrying the same RDS-TMC service */ +}; + /* struct to encapsulate an additional data field in a TMC message */ struct v4l2_tmc_additional { uint8_t label; @@ -225,6 +261,9 @@ struct v4l2_rds_tmc { uint8_t t_d;/* delay time (only if mode = enhanced */ uint8_t spn[9]; /* service provider name */ struct v4l2_rds_tmc_msg tmc_msg; + + /* tuning information for alternative service providers */ + struct v4l2_tmc_tuning tuning; }; /* struct to encapsulate state and RDS information for current decoding process */ diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c index 3a90a3b..3995c3d 100644 --- a/lib/libv4l2rds/libv4l2rds.c +++ b/lib/libv4l2rds/libv4l2rds.c @@ -93,7 +93,9 @@ enum rds_state { }; /* function declarations to prevent the need to move large code blocks */ +static int rds_add_tmc_station(struct rds_private_state *priv_state, uint16_t pi); static uint32_t rds_decode_af(uint8_t af, bool is_vhf); +static bool rds_add_tmc_af(struct rds_private_state *priv_state); static inline uint8_t set_bit(uint8_t input, uint8_t bitmask, bool bitvalue) { @@ -437,6 +439,59 @@ static uint32_t rds_decode_tmc_multi_group(struct rds_private_state *priv_state) return V4L2_RDS_TMC_MG; } +/* decode the RDS-TMC tuning information that is contained in type 8A groups + * (variants 4 to 9) that announce the presence alternative transmitters + * providing the same RDS-TMC service */ +static uint32_t rds_decode_tmc_tuning(struct rds_private_state *priv_state) +{ + struct v4l2_rds_group *group = priv_state-rds_group; + struct v4l2_rds_tmc *tmc = priv_state-handle.tmc; + uint8_t variant_code = group-data_b_lsb 0x0f; + uint16_t pi_on = (group-data_d_msb 8) | group-data_d_lsb; + uint8_t index
[RFC PATCH 4/4] rds-ctl.cpp: added functionality to print RDS-TMC tuning information
Signed-off-by: Konke Radlow korad...@gmail.com --- utils/rds-ctl/rds-ctl.cpp | 28 +++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp index 51536cf..445c11f 100644 --- a/utils/rds-ctl/rds-ctl.cpp +++ b/utils/rds-ctl/rds-ctl.cpp @@ -517,6 +517,30 @@ static void print_rds_tmc(const struct v4l2_rds *handle, uint32_t updated_fields } } +static void print_rds_tmc_tuning(const struct v4l2_rds *handle, uint32_t updated_fields) +{ + const struct v4l2_tmc_tuning *tuning = handle-tmc.tuning; + const struct v4l2_tmc_station *station; + + if (updated_fields V4L2_RDS_TMC_TUNING) { + printf(\nTMC Service provider: %s, %u alternative stations\n, handle-tmc.spn, tuning-station_cnt); + for (int i = 0; i tuning-station_cnt; i++) { + station = tuning-station[i]; + printf(PI(ON %02u) = %04x, AFs: %u, mapped AFs: %u \n, i, station-pi, + station-afi.af_size, station-afi.mapped_af_size); + for (int j = 0; j station-afi.af_size; j++) + printf(AF%02d: %.1fMHz\n, j, station-afi.af[j] / 100.0); + for (int k = 0; k station-afi.mapped_af_size; k++) + printf(m_AF%02d: %.1fMHz = %.1fMHz\n, k, + station-afi.mapped_af_tuning[k] / 100.0, + station-afi.mapped_af[k] / 100.0); + if (station-ltn != 0 || station-msg != 0 || station- sid != 0) + printf(ltn: %02x, msg: %02x, sid: %02x\n, station-ltn, + station-msg, station-sid); + } + } +} + static void print_rds_statistics(const struct v4l2_rds_statistics *statistics) { printf(\n\nRDS Statistics: \n); @@ -636,8 +660,10 @@ static void print_rds_data(const struct v4l2_rds *handle, uint32_t updated_field print_rds_af(handle-rds_af); if (params.options[OptPrintBlock]) printf(\n); - if (params.options[OptTMC]) + if (params.options[OptTMC]) { print_rds_tmc(handle, updated_fields); + print_rds_tmc_tuning(handle, updated_fields); + } } static void read_rds(struct v4l2_rds *handle, const int fd, const int wait_limit) -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCHv2 0/1] Adding core TMC decoding support to RDS library
this patch is an updated version of the last RDS-TMC core support patch. The changes proposed by Hans Verkuil were implemented. In addition the handling and decoding of multi-group TMC messages was heavily modified, in order to improve read- and maintainability Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCHv2] Add core TMC (Traffic Message Channel) support
Signed-off-by: Konke Radlow korad...@gmail.com --- lib/include/libv4l2rds.h| 65 + lib/libv4l2rds/libv4l2rds.c | 309 ++- utils/rds-ctl/rds-ctl.cpp | 31 - 3 files changed, 402 insertions(+), 3 deletions(-) diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h index d8baf15..3ec7735 100644 --- a/lib/include/libv4l2rds.h +++ b/lib/include/libv4l2rds.h @@ -46,6 +46,10 @@ extern C { * AF Method B does not impose a limit on the number of AFs * but it is not fully supported at the moment and will * not receive more than 25 AFs */ +#define MAX_TMC_ADDITIONAL 28 /* 28 is the maximal possible number of fields. + * Additional data is limited to 112 bit, and the smallest + * optional tuple has a size of 4 bit (4 bit identifier + + * 0 bits of data) */ /* Define Constants for the possible types of RDS information * used to address the relevant bit in the valid_fields bitmask */ @@ -63,6 +67,9 @@ extern C { #define V4L2_RDS_AF0x800 /* AF (alternative freq) available */ #define V4L2_RDS_ECC 0x1000 /* Extended County Code */ #define V4L2_RDS_LC0x2000 /* Language Code */ +#define V4L2_RDS_TMC_SG0x4000 /* RDS-TMC single group */ +#define V4L2_RDS_TMC_MG0x8000 /* RDS-TMC multi group */ +#define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */ @@ -76,6 +83,11 @@ extern C { #define V4L2_RDS_FLAG_COMPRESSED 0x04 #define V4L2_RDS_FLAG_STATIC_PTY 0x08 +/* TMC related codes + * used to extract TMC fields from RDS groups */ +#define V4L2_TMC_TUNING_INFO 0x08 +#define V4L2_TMC_SINGLE_GROUP 0x04 + /* struct to encapsulate one complete RDS group */ /* This structure is used internally to store data until a complete RDS * group was received and group id dependent decoding can be done. @@ -137,6 +149,58 @@ struct v4l2_rds_af_set { uint32_t af[MAX_AF_CNT];/* AFs defined in Hz */ }; +/* struct to encapsulate an additional data field in a TMC message */ +struct v4l2_tmc_additional { + uint8_t label; + uint16_t data; +}; + +/* struct to encapsulate an arbitrary number of additional data fields + * belonging to one TMC message */ +struct v4l2_tmc_additional_set { + uint8_t size; + struct v4l2_tmc_additional fields[MAX_TMC_ADDITIONAL]; +}; + +/* struct to encapsulate a decoded TMC message with optional additional + * data field (in case of a multi-group TMC message) */ +struct v4l2_rds_tmc_msg { + uint8_t length; /* length of multi-group message (0..4) */ + uint8_t sid;/* service identifier at time of reception */ + uint8_t extent; + uint8_t dp; /* duration and persistence */ + uint16_t event; /* TMC event code */ + uint16_t location; /* TMC event location */ + bool follow_diversion; /* indicates if the driver is adviced to +* follow the diversion */ + bool neg_direction; /* indicates negative / positive direction */ + + /* decoded additional information (only available in multi-group +* messages) */ + struct v4l2_tmc_additional_set additional; +}; + +/* struct to encapsulate all TMC related information, including TMC System + * Information, TMC Tuning information and a buffer for the last decoded + * TMC messages */ +struct v4l2_rds_tmc { + uint8_t ltn;/* location_table_number */ + bool afi; /* alternative frequency indicator */ + bool enhanced_mode; /* mode of transmission, +* if false - basic = gaps between tmc groups +* gap defines timing behavior +* if true - enhanced = t_a, t_w and t_d +* define timing behavior of tmc groups */ + uint8_t mgs;/* message geographical scope */ + uint8_t sid;/* service identifier (unique ID on national level) */ + uint8_t gap;/* Gap parameters */ + uint8_t t_a;/* activity time (only if mode = enhanced) */ + uint8_t t_w;/* window time (only if mode = enhanced */ + uint8_t t_d;/* delay time (only if mode = enhanced */ + uint8_t spn[9]; /* service provider name */ + struct v4l2_rds_tmc_msg tmc_msg; +}; + /* struct to encapsulate state and RDS information for current decoding process */ /* This is the structure that will be used by external applications, to * communicate with the library and get access to RDS data */ @@ -172,6 +236,7 @@ struct v4l2_rds
[PATCH 0/2] Add support for RDS decoding
Hello, after the positive feedback from the last RFC session, here now a patch including all minor changes that were proposed. Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] Add libv4l2rds library
Signed-off-by: Konke Radlow korad...@gmail.com --- Makefile.am |3 +- configure.ac|2 + lib/include/libv4l2rds.h| 218 + lib/libv4l2rds/Makefile.am | 11 + lib/libv4l2rds/libv4l2rds.c | 965 +++ lib/libv4l2rds/libv4l2rds.pc.in | 11 + 6 files changed, 1209 insertions(+), 1 deletion(-) create mode 100644 lib/include/libv4l2rds.h create mode 100644 lib/libv4l2rds/Makefile.am create mode 100644 lib/libv4l2rds/libv4l2rds.c create mode 100644 lib/libv4l2rds/libv4l2rds.pc.in diff --git a/Makefile.am b/Makefile.am index a754955..621d8d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ SUBDIRS = \ lib/libv4lconvert \ lib/libv4l2 \ lib/libv4l1 \ - lib/libdvbv5 + lib/libdvbv5 \ + lib/libv4l2rds if WITH_V4LUTILS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index 8ddcc9d..bc9ba14 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l2/Makefile lib/libv4l1/Makefile lib/libdvbv5/Makefile + lib/libv4l2rds/Makefile utils/libv4l2util/Makefile utils/libmedia_dev/Makefile @@ -36,6 +37,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l1/libv4l1.pc lib/libv4l2/libv4l2.pc lib/libdvbv5/libdvbv5.pc + lib/libv4l2rds/libv4l2rds.pc ]) AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-bzip2 -Wno-portability]) # 1.10 is needed for target_LIBTOOLFLAGS diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h new file mode 100644 index 000..37bdd2f --- /dev/null +++ b/lib/include/libv4l2rds.h @@ -0,0 +1,218 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow krad...@cisco.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#ifndef __LIBV4L2RDS +#define __LIBV4L2RDS + + +#include stdbool.h +#include stdint.h + +#include linux/videodev2.h + +#ifdef __cplusplus +extern C { +#endif /* __cplusplus */ + +#if HAVE_VISIBILITY +#define LIBV4L_PUBLIC __attribute__ ((visibility(default))) +#else +#define LIBV4L_PUBLIC +#endif + +/* used to define the current version (version field) of the v4l2_rds struct */ +#define V4L2_RDS_VERSION (1) + +/* Constants used to define the size of arrays used to store RDS information */ +#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these +* 32 distinct groups, 18 can be used for ODA purposes */ +#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined +* AF Method B does not impose a limit on the number of AFs +* but it is not fully supported at the moment and will +* not receive more than 25 AFs */ + +/* Define Constants for the possible types of RDS information + * used to address the relevant bit in the valid_fields bitmask */ +#define V4L2_RDS_PI0x01/* Program Identification */ +#define V4L2_RDS_PTY 0x02/* Program Type */ +#define V4L2_RDS_TP0x04/* Traffic Program */ +#define V4L2_RDS_PS0x08/* Program Service Name */ +#define V4L2_RDS_TA0x10/* Traffic Announcement */ +#define V4L2_RDS_DI0x20/* Decoder Information */ +#define V4L2_RDS_MS0x40/* Music / Speech flag */ +#define V4L2_RDS_PTYN 0x80/* Program Type Name */ +#define V4L2_RDS_RT0x100 /* Radio-Text */ +#define V4L2_RDS_TIME 0x200 /* Date and Time information */ +#define V4L2_RDS_TMC 0x400 /* TMC availability */ +#define V4L2_RDS_AF0x800 /* AF (alternative freq) available */ +#define V4L2_RDS_ECC 0x1000 /* Extended County Code */ +#define V4L2_RDS_LC0x2000 /* Language Code */ + +/* Define Constants for the state of the RDS decoding process + * used to address the relevant bit in the decode_information bitmask */ +#define V4L2_RDS_GROUP_NEW 0x01/* New group received */ +#define V4L2_RDS_ODA 0x02/* Open Data Group announced */ + +/* Decoder Information (DI) codes + * used to decode the DI information according to the RDS standard
[PATCH 2/2] Add rds-ctl tool
Signed-off-by: Konke Radlow korad...@gmail.com --- Makefile.am |3 +- configure.ac |1 + utils/rds-ctl/Makefile.am |5 + utils/rds-ctl/rds-ctl.cpp | 938 + 4 files changed, 946 insertions(+), 1 deletion(-) create mode 100644 utils/rds-ctl/Makefile.am create mode 100644 utils/rds-ctl/rds-ctl.cpp diff --git a/Makefile.am b/Makefile.am index 621d8d9..8ef0d00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,8 @@ SUBDIRS += \ utils/v4l2-compliance \ utils/v4l2-ctl \ utils/v4l2-dbg \ - utils/v4l2-sysfs-path + utils/v4l2-sysfs-path \ + utils/rds-ctl if LINUX_OS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index bc9ba14..a1d26b6 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_CONFIG_FILES([Makefile utils/v4l2-sysfs-path/Makefile utils/xc3028-firmware/Makefile utils/qv4l2/Makefile + utils/rds-ctl/Makefile contrib/freebsd/Makefile contrib/test/Makefile diff --git a/utils/rds-ctl/Makefile.am b/utils/rds-ctl/Makefile.am new file mode 100644 index 000..9a84257 --- /dev/null +++ b/utils/rds-ctl/Makefile.am @@ -0,0 +1,5 @@ +bin_PROGRAMS = rds-ctl + +rds_ctl_SOURCES = rds-ctl.cpp +rds_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4l2rds/libv4l2rds.la + diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp new file mode 100644 index 000..262773c --- /dev/null +++ b/utils/rds-ctl/rds-ctl.cpp @@ -0,0 +1,938 @@ +/* + * rds-ctl.cpp is based on v4l2-ctl.cpp + * + * the following applies for all RDS related parts: + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow krad...@cisco.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#include unistd.h +#include stdlib.h +#include stdio.h +#include string.h +#include wchar.h +#include locale.h +#include inttypes.h +#include getopt.h +#include sys/types.h +#include fcntl.h +#include errno.h +#include sys/ioctl.h +#include sys/time.h +#include dirent.h +#include config.h +#include signal.h + +#include linux/videodev2.h +#include libv4l2.h +#include libv4l2rds.h + +#include list +#include vector +#include map +#include string +#include algorithm + +#define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) + +typedef std::vectorstd::string dev_vec; +typedef std::mapstd::string, std::string dev_map; + +/* Short option list + + Please keep in alphabetical order. + That makes it easier to see which short options are still free. + + In general the lower case is used to set something and the upper + case is used to retrieve a setting. */ +enum Option { + OptSetDevice = 'd', + OptGetDriverInfo = 'D', + OptGetFreq = 'F', + OptSetFreq = 'f', + OptHelp = 'h', + OptReadRds = 'R', + OptGetTuner = 'T', + OptSetTuner = 't', + OptUseWrapper = 'w', + OptAll = 128, + OptFreqSeek, + OptListDevices, + OptListFreqBands, + OptOpenFile, + OptPrintBlock, + OptSilent, + OptTunerIndex, + OptVerbose, + OptWaitLimit, + OptLast = 256 +}; + +struct ctl_parameters { + bool terminate_decoding; + char options[OptLast]; + char fd_name[80]; + bool filemode_active; + double freq; + uint32_t wait_limit; + uint8_t tuner_index; + struct v4l2_hw_freq_seek freq_seek; +}; + +static struct ctl_parameters params; +static int app_result; + +static struct option long_options[] = { + {all, no_argument, 0, OptAll}, + {device, required_argument, 0, OptSetDevice}, + {file, required_argument, 0, OptOpenFile}, + {freq-seek, required_argument, 0, OptFreqSeek}, + {get-freq, no_argument, 0, OptGetFreq}, + {get-tuner, no_argument, 0, OptGetTuner}, + {help, no_argument, 0, OptHelp}, + {info, no_argument, 0, OptGetDriverInfo}, + {list-devices, no_argument, 0, OptListDevices}, + {list-freq-bands, no_argument, 0, OptListFreqBands}, + {print-block, no_argument, 0, OptPrintBlock}, + {read-rds, no_argument, 0, OptReadRds}, + {set-freq, required_argument, 0, OptSetFreq}, + {tuner-index
[PATCHv2 0/2] Add support for RDS decoding
Hello, after the positive feedback from the last RFC session, here now a patch including all minor changes that were proposed. embarrassingly, I missed a minor bug introduced by removing the version field from the v4l2_rds struct, hence the resend Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv2 2/2] Add rds-ctl tool
Signed-off-by: Konke Radlow korad...@gmail.com --- Makefile.am |3 +- configure.ac |1 + utils/rds-ctl/Makefile.am |5 + utils/rds-ctl/rds-ctl.cpp | 938 + 4 files changed, 946 insertions(+), 1 deletion(-) create mode 100644 utils/rds-ctl/Makefile.am create mode 100644 utils/rds-ctl/rds-ctl.cpp diff --git a/Makefile.am b/Makefile.am index 621d8d9..8ef0d00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,8 @@ SUBDIRS += \ utils/v4l2-compliance \ utils/v4l2-ctl \ utils/v4l2-dbg \ - utils/v4l2-sysfs-path + utils/v4l2-sysfs-path \ + utils/rds-ctl if LINUX_OS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index bc9ba14..a1d26b6 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_CONFIG_FILES([Makefile utils/v4l2-sysfs-path/Makefile utils/xc3028-firmware/Makefile utils/qv4l2/Makefile + utils/rds-ctl/Makefile contrib/freebsd/Makefile contrib/test/Makefile diff --git a/utils/rds-ctl/Makefile.am b/utils/rds-ctl/Makefile.am new file mode 100644 index 000..9a84257 --- /dev/null +++ b/utils/rds-ctl/Makefile.am @@ -0,0 +1,5 @@ +bin_PROGRAMS = rds-ctl + +rds_ctl_SOURCES = rds-ctl.cpp +rds_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4l2rds/libv4l2rds.la + diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp new file mode 100644 index 000..262773c --- /dev/null +++ b/utils/rds-ctl/rds-ctl.cpp @@ -0,0 +1,938 @@ +/* + * rds-ctl.cpp is based on v4l2-ctl.cpp + * + * the following applies for all RDS related parts: + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow krad...@cisco.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#include unistd.h +#include stdlib.h +#include stdio.h +#include string.h +#include wchar.h +#include locale.h +#include inttypes.h +#include getopt.h +#include sys/types.h +#include fcntl.h +#include errno.h +#include sys/ioctl.h +#include sys/time.h +#include dirent.h +#include config.h +#include signal.h + +#include linux/videodev2.h +#include libv4l2.h +#include libv4l2rds.h + +#include list +#include vector +#include map +#include string +#include algorithm + +#define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) + +typedef std::vectorstd::string dev_vec; +typedef std::mapstd::string, std::string dev_map; + +/* Short option list + + Please keep in alphabetical order. + That makes it easier to see which short options are still free. + + In general the lower case is used to set something and the upper + case is used to retrieve a setting. */ +enum Option { + OptSetDevice = 'd', + OptGetDriverInfo = 'D', + OptGetFreq = 'F', + OptSetFreq = 'f', + OptHelp = 'h', + OptReadRds = 'R', + OptGetTuner = 'T', + OptSetTuner = 't', + OptUseWrapper = 'w', + OptAll = 128, + OptFreqSeek, + OptListDevices, + OptListFreqBands, + OptOpenFile, + OptPrintBlock, + OptSilent, + OptTunerIndex, + OptVerbose, + OptWaitLimit, + OptLast = 256 +}; + +struct ctl_parameters { + bool terminate_decoding; + char options[OptLast]; + char fd_name[80]; + bool filemode_active; + double freq; + uint32_t wait_limit; + uint8_t tuner_index; + struct v4l2_hw_freq_seek freq_seek; +}; + +static struct ctl_parameters params; +static int app_result; + +static struct option long_options[] = { + {all, no_argument, 0, OptAll}, + {device, required_argument, 0, OptSetDevice}, + {file, required_argument, 0, OptOpenFile}, + {freq-seek, required_argument, 0, OptFreqSeek}, + {get-freq, no_argument, 0, OptGetFreq}, + {get-tuner, no_argument, 0, OptGetTuner}, + {help, no_argument, 0, OptHelp}, + {info, no_argument, 0, OptGetDriverInfo}, + {list-devices, no_argument, 0, OptListDevices}, + {list-freq-bands, no_argument, 0, OptListFreqBands}, + {print-block, no_argument, 0, OptPrintBlock}, + {read-rds, no_argument, 0, OptReadRds}, + {set-freq, required_argument, 0, OptSetFreq}, + {tuner-index
[PATCHv2 1/2] Add libv4l2rds library
Signed-off-by: Konke Radlow korad...@gmail.com --- Makefile.am |3 +- configure.ac|2 + lib/include/libv4l2rds.h| 218 + lib/libv4l2rds/Makefile.am | 11 + lib/libv4l2rds/libv4l2rds.c | 964 +++ lib/libv4l2rds/libv4l2rds.pc.in | 11 + 6 files changed, 1208 insertions(+), 1 deletion(-) create mode 100644 lib/include/libv4l2rds.h create mode 100644 lib/libv4l2rds/Makefile.am create mode 100644 lib/libv4l2rds/libv4l2rds.c create mode 100644 lib/libv4l2rds/libv4l2rds.pc.in diff --git a/Makefile.am b/Makefile.am index a754955..621d8d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ SUBDIRS = \ lib/libv4lconvert \ lib/libv4l2 \ lib/libv4l1 \ - lib/libdvbv5 + lib/libdvbv5 \ + lib/libv4l2rds if WITH_V4LUTILS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index 8ddcc9d..bc9ba14 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l2/Makefile lib/libv4l1/Makefile lib/libdvbv5/Makefile + lib/libv4l2rds/Makefile utils/libv4l2util/Makefile utils/libmedia_dev/Makefile @@ -36,6 +37,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l1/libv4l1.pc lib/libv4l2/libv4l2.pc lib/libdvbv5/libdvbv5.pc + lib/libv4l2rds/libv4l2rds.pc ]) AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-bzip2 -Wno-portability]) # 1.10 is needed for target_LIBTOOLFLAGS diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h new file mode 100644 index 000..37bdd2f --- /dev/null +++ b/lib/include/libv4l2rds.h @@ -0,0 +1,218 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow krad...@cisco.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#ifndef __LIBV4L2RDS +#define __LIBV4L2RDS + + +#include stdbool.h +#include stdint.h + +#include linux/videodev2.h + +#ifdef __cplusplus +extern C { +#endif /* __cplusplus */ + +#if HAVE_VISIBILITY +#define LIBV4L_PUBLIC __attribute__ ((visibility(default))) +#else +#define LIBV4L_PUBLIC +#endif + +/* used to define the current version (version field) of the v4l2_rds struct */ +#define V4L2_RDS_VERSION (1) + +/* Constants used to define the size of arrays used to store RDS information */ +#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these +* 32 distinct groups, 18 can be used for ODA purposes */ +#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined +* AF Method B does not impose a limit on the number of AFs +* but it is not fully supported at the moment and will +* not receive more than 25 AFs */ + +/* Define Constants for the possible types of RDS information + * used to address the relevant bit in the valid_fields bitmask */ +#define V4L2_RDS_PI0x01/* Program Identification */ +#define V4L2_RDS_PTY 0x02/* Program Type */ +#define V4L2_RDS_TP0x04/* Traffic Program */ +#define V4L2_RDS_PS0x08/* Program Service Name */ +#define V4L2_RDS_TA0x10/* Traffic Announcement */ +#define V4L2_RDS_DI0x20/* Decoder Information */ +#define V4L2_RDS_MS0x40/* Music / Speech flag */ +#define V4L2_RDS_PTYN 0x80/* Program Type Name */ +#define V4L2_RDS_RT0x100 /* Radio-Text */ +#define V4L2_RDS_TIME 0x200 /* Date and Time information */ +#define V4L2_RDS_TMC 0x400 /* TMC availability */ +#define V4L2_RDS_AF0x800 /* AF (alternative freq) available */ +#define V4L2_RDS_ECC 0x1000 /* Extended County Code */ +#define V4L2_RDS_LC0x2000 /* Language Code */ + +/* Define Constants for the state of the RDS decoding process + * used to address the relevant bit in the decode_information bitmask */ +#define V4L2_RDS_GROUP_NEW 0x01/* New group received */ +#define V4L2_RDS_ODA 0x02/* Open Data Group announced */ + +/* Decoder Information (DI) codes + * used to decode the DI information according to the RDS standard
[RFC PATCH 0/1] Adding core TMC decoding support to RDS library
Hello, this patch adds the core of TMC decoding support to the RDS library. Single and multigroup TMC messages as well as TMC system messages are decoded into an easily accessable format and can be used as the basis for a complete TMC decoding implementation. The part that's missing from the code are the extensive lookup-tables that necessary to decode the dictionary-based TMC protocol into a human readable representation. As these LUTs are just the next layer in TMC decoding and don't add a lot of complexity or logic to the code it was decided to release an [RFC PATCH] at the current state, so that it might be merged into the master branch together with the RDS-decoding library. Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH] Add core TMC (Traffic Message Channel) support
Signed-off-by: Konke Radlow korad...@gmail.com --- lib/include/libv4l2rds.h| 64 lib/libv4l2rds/libv4l2rds.c | 340 ++- utils/rds-ctl/rds-ctl.cpp | 31 +++- 3 files changed, 432 insertions(+), 3 deletions(-) diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h index 37bdd2f..caefc1a 100644 --- a/lib/include/libv4l2rds.h +++ b/lib/include/libv4l2rds.h @@ -63,6 +63,9 @@ extern C { #define V4L2_RDS_AF0x800 /* AF (alternative freq) available */ #define V4L2_RDS_ECC 0x1000 /* Extended County Code */ #define V4L2_RDS_LC0x2000 /* Language Code */ +#define V4L2_RDS_TMC_SG0x4000 /* RDS-TMC single group */ +#define V4L2_RDS_TMC_MG0x8000 /* RDS-TMC multi group */ +#define V4L2_RDS_TMC_SYS 0x1 /* RDS-TMC system information */ /* Define Constants for the state of the RDS decoding process * used to address the relevant bit in the decode_information bitmask */ @@ -76,6 +79,11 @@ extern C { #define V4L2_RDS_FLAG_COMPRESSED 0x04 #define V4L2_RDS_FLAG_STATIC_PTY 0x08 +/* TMC related codes + * used to extract TMC fields from RDS groups */ +#define V4L2_TMC_TUNING_INFO 0x08 +#define V4L2_TMC_SINGLE_GROUP 0x04 + /* struct to encapsulate one complete RDS group */ /* This structure is used internally to store data until a complete RDS * group was received and group id dependent decoding can be done. @@ -137,6 +145,61 @@ struct v4l2_rds_af_set { uint32_t af[MAX_AF_CNT];/* AFs defined in Hz */ }; +/* struct to encapsulate an additional data field in a TMC message */ +struct v4l2_tmc_additional { + uint8_t label; + uint16_t data; +}; + +/* struct to encapsulate an arbitrary number of additional data fields + * belonging to one TMC message */ +struct v4l2_tmc_additional_set { + uint8_t size; + /* 28 is the maximal possible number of fields. Additional data +* is limited to 112 bit, and the smallest optional tuple has +* a size of 4 bit (4 bit identifier + 0 bits of data) */ + struct v4l2_tmc_additional fields[28]; +}; + +/* struct to encapsulate a decoded TMC message with optional additional + * data field (in case of a multi-group TMC message) */ +struct v4l2_rds_tmc_msg { + uint8_t length; /* length of multi-group message (0..4) */ + uint8_t sid;/* service identifier at time of reception */ + uint8_t extent; + uint8_t dp; /* duration and persistence */ + uint16_t event; /* TMC event code */ + uint16_t location; /* TMC event location */ + bool follow_diversion; /* indicates if the driver is adviced to +* follow the diversion */ + bool neg_direction; /* indicates negative / positive direction */ + + /* decoded additional information (only available in multi-group +* messages) */ + struct v4l2_tmc_additional_set additional; +}; + +/* struct to encapsulate all TMC related information, including TMC System + * Information, TMC Tuning information and a buffer for the last decoded + * TMC messages */ +struct v4l2_rds_tmc { + uint8_t ltn;/* location_table_number */ + bool afi; /* alternative frequency indicator */ + bool enhanced_mode; /* mode of transmission, +* if false - basic = gaps between tmc groups +* gap defines timing behavior +* if true - enhanced = t_a, t_w and t_d +* define timing behavior of tmc groups */ + uint8_t mgs;/* message geographical scope */ + uint8_t sid;/* service identifier (unique ID on national level) */ + uint8_t gap;/* Gap parameters */ + uint8_t t_a;/* activity time (only if mode = enhanced) */ + uint8_t t_w;/* window time (only if mode = enhanced */ + uint8_t t_d;/* delay time (only if mode = enhanced */ + uint8_t spn[9]; /* service provider name */ + struct v4l2_rds_tmc_msg tmc_msg; +}; + /* struct to encapsulate state and RDS information for current decoding process */ /* This is the structure that will be used by external applications, to * communicate with the library and get access to RDS data */ @@ -172,6 +235,7 @@ struct v4l2_rds { struct v4l2_rds_statistics rds_statistics; struct v4l2_rds_oda_set rds_oda;/* Open Data Services */ struct v4l2_rds_af_set rds_af; /* Alternative Frequencies */ + struct v4l2_rds_tmc tmc;/* TMC information */ }; /* v4l2_rds_init() - initializes a new decoding process diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c index 2d6642c..f47adb8 100644 --- a/lib/libv4l2rds/libv4l2rds.c +++ b/lib
[Announcement] pcimax3000+ (RDS-transmitter) control tool
Hello, during the last weeks I've been working on a RDS (Radio Data System) decoding library (libv4l2rds) and a corresponding test and control tool (rds-ctl), that might make it into v4l soon. In the course of this process I created a command line tool for controlling the PCIMAX3000+ RDS-transmission card. http://www.pcs-electronics.com/3000-stereo-transmitter-card-p-1664.html? The tool was used to test the library and has reached a stage where it is feature complete and easy to use and setup. For this reason I wanted to share the code in case somebody is interested in setting up his own radio station, or test RDS :) The most recent version of the tool can always be found in my repository: https://github.com/koradlow/pcimax-ctl Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 1/2] Add libv4l2rds library (with changes proposed in RFC)
they are gone. And btw: I'm sorry for fiddling with your build environment in such a way. I have to admit that the additions I made were based more on copying from existing libraries than really understanding the effects of each command. Regards, Konke On Thu, Aug 9, 2012 at 7:22 AM, Gregor Jasny gja...@googlemail.com wrote: Hello Konke, On 8/7/12 5:11 PM, Konke Radlow wrote: diff --git a/configure.ac b/configure.ac index 8ddcc9d..1109c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -146,9 +148,12 @@ AC_ARG_WITH(libv4l2subdir, AS_HELP_STRING(--with-libv4l2subdir=DIR,set libv4l2 l AC_ARG_WITH(libv4lconvertsubdir, AS_HELP_STRING(--with-libv4lconvertsubdir=DIR,set libv4lconvert library subdir [default=libv4l]), libv4lconvertsubdir=$withval, libv4lconvertsubdir=libv4l) +AC_ARG_WITH(libv4l2rdssubdir, AS_HELP_STRING(--with-libv4l2rdssubdir=DIR,set libv4l2rds library subdir [default=libv4l]), + libv4l2rdssubdir=$withval, libv4l2rdssubdir=libv4l) + AC_ARG_WITH(udevdir, AS_HELP_STRING(--with-udevdir=DIR,set udev directory [default=/lib/udev]), udevdir=$withval, udevdir=/lib/udev) - + libv4l1privdir=$libdir/$libv4l1subdir libv4l2privdir=$libdir/$libv4l2subdir libv4l2plugindir=$libv4l2privdir/plugins please remove these changes. They are not needed for the RDS library. Thanks, Gregor -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 1/2] Add libv4l2rds library (with changes proposed in RFC)
On Thu, Aug 9, 2012 at 11:58 AM, Hans de Goede hdego...@redhat.com wrote: Other then that I've some minor remarks (comments inline), with all those fixed, this one is could to go. So hopefully the next version can be added to git master! I'm very happy to hear that :) On 08/07/2012 05:11 PM, Konke Radlow wrote: --- Makefile.am |3 +- configure.ac|7 +- lib/include/libv4l2rds.h| 228 ++ lib/libv4l2rds/Makefile.am | 11 + lib/libv4l2rds/libv4l2rds.c | 953 +++ lib/libv4l2rds/libv4l2rds.pc.in | 11 + 6 files changed, 1211 insertions(+), 2 deletions(-) create mode 100644 lib/include/libv4l2rds.h create mode 100644 lib/libv4l2rds/Makefile.am create mode 100644 lib/libv4l2rds/libv4l2rds.c create mode 100644 lib/libv4l2rds/libv4l2rds.pc.in snip diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h new file mode 100644 index 000..4aa8593 --- /dev/null +++ b/lib/include/libv4l2rds.h @@ -0,0 +1,228 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#ifndef __LIBV4L2RDS +#define __LIBV4L2RDS + +#include errno.h +#include stdio.h +#include stdlib.h +#include string.h +#include stdbool.h +#include unistd.h +#include stdint.h +#include time.h +#include sys/types.h +#include sys/mman.h +#include config.h You should never include config.h in a public header, also are all the headers really needed for the prototypes in this header? I don't think so! Please move all the unneeded ones to the libv4l2rds.c file! That's true, I don't know why I had all these include directives in the public header. After cleaning up we're left with only three (stdbool, stdint and videodev2) + +#include linux/videodev2.h + +#ifdef __cplusplus +extern C { +#endif /* __cplusplus */ + +#if HAVE_VISIBILITY +#define LIBV4L_PUBLIC __attribute__ ((visibility(default))) +#else +#define LIBV4L_PUBLIC +#endif + +/* used to define the current version (version field) of the v4l2_rds struct */ +#define V4L2_RDS_VERSION (1) + What is the purpose of this field? Once we've released a v4l-utils with this library we are stuck to the API we've defined, having a version field changing it, won't stop us from breaking existing apps, so once we've an official release we simply cannot make ABI breaking changes, which is why most of my review sofar has concentrated on the API side :) I suggest dropping this define and the version field from the struct. As Hans mentioned this version field is not supposed to denote the API version, but rather the version of the v4l2_rds_handle struct. This struct could then theoretically be updated in the future and provide applications a way of verifying their compatibility with the rds-library version installed on the system. +/* Constants used to define the size of arrays used to store RDS information */ +#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these +* 32 distinct groups, 18 can be used for ODA purposes */ +#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined +* AF Method B does not impose a limit on the number of AFs +* but it is not fully supported at the moment and will +* not receive more than 25 AFs */ + +/* Define Constants for the possible types of RDS information + * used to address the relevant bit in the valid_fields bitmask */ +#define V4L2_RDS_PI0x01/* Program Identification */ +#define V4L2_RDS_PTY 0x02/* Program Type */ +#define V4L2_RDS_TP0x04/* Traffic Program */ +#define V4L2_RDS_PS0x08/* Program Service Name */ +#define V4L2_RDS_TA0x10/* Traffic Announcement */ +#define V4L2_RDS_DI0x20/* Decoder Information */ +#define V4L2_RDS_MS0x40/* Music / Speech flag */ +#define V4L2_RDS_PTYN 0x80/* Program Type Name */ +#define V4L2_RDS_RT
Re: [RFC PATCH 2/2] Add rds-ctl tool (with changes proposed in RFC)
On Thu, Aug 9, 2012 at 12:05 PM, Hans de Goede hdego...@redhat.com wrote: Hi, Comments inline. On 08/07/2012 05:11 PM, Konke Radlow wrote: --- Makefile.am |3 +- configure.ac |1 + utils/rds-ctl/Makefile.am |5 + utils/rds-ctl/rds-ctl.cpp | 959 + 4 files changed, 967 insertions(+), 1 deletion(-) create mode 100644 utils/rds-ctl/Makefile.am create mode 100644 utils/rds-ctl/rds-ctl.cpp diff --git a/Makefile.am b/Makefile.am index 621d8d9..8ef0d00 100644 --- a/Makefile.am +++ b/Makefile.am Snip +static void print_rds_data(const struct v4l2_rds *handle, uint32_t updated_fields) +{ + if (params.options[OptPrintBlock]) + updated_fields = 0x; + + if ((updated_fields V4L2_RDS_PI) + (handle-valid_fields V4L2_RDS_PI)) { + printf(\nPI: %04x, handle-pi); + print_rds_pi(handle); + } + + if (updated_fields V4L2_RDS_PS + handle-valid_fields V4L2_RDS_PS) { + printf(\nPS: ); + for (int i = 0; i 8; ++i) { + /* filter out special characters */ + if (handle-ps[i] = 0x20 handle-ps[i] = 0x7E) + printf(%lc,handle-ps[i]); + else + printf( ); + } Since ps now is a 0 terminated UTF-8 string you should be able to just do: printf(\nPS: %s, handle-ps); And likewise for the other strings. changed as proposed, and works like a charm :) Other then that this looks good to me. Regards, Hans thank you for the review Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 0/2] Add support for RDS decoding (updated)
just for the record, these patches are: Signed-off-by: Konke Radlow krad...@cisco.com Regards, Konke On Tue, Aug 7, 2012 at 3:11 PM, Konke Radlow krad...@cisco.com wrote: Hello, first of all: thank you for the comments to my previous RFC for the libv4l2rds library and the rds-ctl control testing tool. The proposed changes have been implemented, and the code has been further improved after a thorough code review by Hans Verkuil. Changes: -the code is rebased on the latest v4l-utils code (as of today 07.08) -added feature: time/date decoding -implementing proposed changes -code cleanup -extended comments Status: From my point of view the RDS decoding is now almost feature complete. There are some obscure RDS features like paging that are not supported, but they do not seem to used anywhere. So in the near future no features will be added and the goal is to get the library and control tool merged into the v4l-utils codebase. Upcoming: Work on RDS-TMC decoding is going well and is being done in a seperate branch. It will be the subject of a future RFC, once it has reached a mature stage. But TMC is not a core feature of RDS but an addition. Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 0/2] Add support for RDS decoding (updated)
Hello, first of all: thank you for the comments to my previous RFC for the libv4l2rds library and the rds-ctl control testing tool. The proposed changes have been implemented, and the code has been further improved after a thorough code review by Hans Verkuil. Changes: -the code is rebased on the latest v4l-utils code (as of today 07.08) -added feature: time/date decoding -implementing proposed changes -code cleanup -extended comments Status: From my point of view the RDS decoding is now almost feature complete. There are some obscure RDS features like paging that are not supported, but they do not seem to used anywhere. So in the near future no features will be added and the goal is to get the library and control tool merged into the v4l-utils codebase. Upcoming: Work on RDS-TMC decoding is going well and is being done in a seperate branch. It will be the subject of a future RFC, once it has reached a mature stage. But TMC is not a core feature of RDS but an addition. Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 2/2] Add rds-ctl tool (with changes proposed in RFC)
--- Makefile.am |3 +- configure.ac |1 + utils/rds-ctl/Makefile.am |5 + utils/rds-ctl/rds-ctl.cpp | 959 + 4 files changed, 967 insertions(+), 1 deletion(-) create mode 100644 utils/rds-ctl/Makefile.am create mode 100644 utils/rds-ctl/rds-ctl.cpp diff --git a/Makefile.am b/Makefile.am index 621d8d9..8ef0d00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,8 @@ SUBDIRS += \ utils/v4l2-compliance \ utils/v4l2-ctl \ utils/v4l2-dbg \ - utils/v4l2-sysfs-path + utils/v4l2-sysfs-path \ + utils/rds-ctl if LINUX_OS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index 1109c4d..a99f1c6 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_CONFIG_FILES([Makefile utils/v4l2-sysfs-path/Makefile utils/xc3028-firmware/Makefile utils/qv4l2/Makefile + utils/rds-ctl/Makefile contrib/freebsd/Makefile contrib/test/Makefile diff --git a/utils/rds-ctl/Makefile.am b/utils/rds-ctl/Makefile.am new file mode 100644 index 000..9a84257 --- /dev/null +++ b/utils/rds-ctl/Makefile.am @@ -0,0 +1,5 @@ +bin_PROGRAMS = rds-ctl + +rds_ctl_SOURCES = rds-ctl.cpp +rds_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4l2rds/libv4l2rds.la + diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp new file mode 100644 index 000..072ffb7 --- /dev/null +++ b/utils/rds-ctl/rds-ctl.cpp @@ -0,0 +1,959 @@ +/* + * rds-ctl.cpp is based on v4l2-ctl.cpp + * + * the following applies for all RDS related parts: + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#include unistd.h +#include stdlib.h +#include stdio.h +#include string.h +#include wchar.h +#include locale.h +#include inttypes.h +#include getopt.h +#include sys/types.h +#include fcntl.h +#include errno.h +#include sys/ioctl.h +#include sys/time.h +#include dirent.h +#include config.h +#include signal.h + +#include linux/videodev2.h +#include libv4l2.h +#include libv4l2rds.h + +#include list +#include vector +#include map +#include string +#include algorithm + +#define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) + +typedef std::vectorstd::string dev_vec; +typedef std::mapstd::string, std::string dev_map; + +/* Short option list + + Please keep in alphabetical order. + That makes it easier to see which short options are still free. + + In general the lower case is used to set something and the upper + case is used to retrieve a setting. */ +enum Option { + OptSetDevice = 'd', + OptGetDriverInfo = 'D', + OptGetFreq = 'F', + OptSetFreq = 'f', + OptHelp = 'h', + OptReadRds = 'R', + OptGetTuner = 'T', + OptSetTuner = 't', + OptUseWrapper = 'w', + OptAll = 128, + OptFreqSeek, + OptListDevices, + OptListFreqBands, + OptOpenFile, + OptPrintBlock, + OptSilent, + OptTunerIndex, + OptVerbose, + OptWaitLimit, + OptLast = 256 +}; + +struct ctl_parameters { + bool terminate_decoding; + char options[OptLast]; + char fd_name[80]; + bool filemode_active; + double freq; + uint32_t wait_limit; + uint8_t tuner_index; + struct v4l2_hw_freq_seek freq_seek; +}; + +static struct ctl_parameters params; +static int app_result; + +static struct option long_options[] = { + {all, no_argument, 0, OptAll}, + {device, required_argument, 0, OptSetDevice}, + {file, required_argument, 0, OptOpenFile}, + {freq-seek, required_argument, 0, OptFreqSeek}, + {get-freq, no_argument, 0, OptGetFreq}, + {get-tuner, no_argument, 0, OptGetTuner}, + {help, no_argument, 0, OptHelp}, + {info, no_argument, 0, OptGetDriverInfo}, + {list-devices, no_argument, 0, OptListDevices}, + {list-freq-bands, no_argument, 0, OptListFreqBands}, + {print-block, no_argument, 0, OptPrintBlock}, + {read-rds, no_argument, 0, OptReadRds}, + {set-freq, required_argument, 0, OptSetFreq}, + {tuner-index, required_argument, 0, OptTunerIndex}, + {verbose
[RFC PATCH 1/2] Add libv4l2rds library (with changes proposed in RFC)
--- Makefile.am |3 +- configure.ac|7 +- lib/include/libv4l2rds.h| 228 ++ lib/libv4l2rds/Makefile.am | 11 + lib/libv4l2rds/libv4l2rds.c | 953 +++ lib/libv4l2rds/libv4l2rds.pc.in | 11 + 6 files changed, 1211 insertions(+), 2 deletions(-) create mode 100644 lib/include/libv4l2rds.h create mode 100644 lib/libv4l2rds/Makefile.am create mode 100644 lib/libv4l2rds/libv4l2rds.c create mode 100644 lib/libv4l2rds/libv4l2rds.pc.in diff --git a/Makefile.am b/Makefile.am index a754955..621d8d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ SUBDIRS = \ lib/libv4lconvert \ lib/libv4l2 \ lib/libv4l1 \ - lib/libdvbv5 + lib/libdvbv5 \ + lib/libv4l2rds if WITH_V4LUTILS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index 8ddcc9d..1109c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l2/Makefile lib/libv4l1/Makefile lib/libdvbv5/Makefile + lib/libv4l2rds/Makefile utils/libv4l2util/Makefile utils/libmedia_dev/Makefile @@ -36,6 +37,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l1/libv4l1.pc lib/libv4l2/libv4l2.pc lib/libdvbv5/libdvbv5.pc + lib/libv4l2rds/libv4l2rds.pc ]) AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-bzip2 -Wno-portability]) # 1.10 is needed for target_LIBTOOLFLAGS @@ -146,9 +148,12 @@ AC_ARG_WITH(libv4l2subdir, AS_HELP_STRING(--with-libv4l2subdir=DIR,set libv4l2 l AC_ARG_WITH(libv4lconvertsubdir, AS_HELP_STRING(--with-libv4lconvertsubdir=DIR,set libv4lconvert library subdir [default=libv4l]), libv4lconvertsubdir=$withval, libv4lconvertsubdir=libv4l) +AC_ARG_WITH(libv4l2rdssubdir, AS_HELP_STRING(--with-libv4l2rdssubdir=DIR,set libv4l2rds library subdir [default=libv4l]), + libv4l2rdssubdir=$withval, libv4l2rdssubdir=libv4l) + AC_ARG_WITH(udevdir, AS_HELP_STRING(--with-udevdir=DIR,set udev directory [default=/lib/udev]), udevdir=$withval, udevdir=/lib/udev) - + libv4l1privdir=$libdir/$libv4l1subdir libv4l2privdir=$libdir/$libv4l2subdir libv4l2plugindir=$libv4l2privdir/plugins diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h new file mode 100644 index 000..4aa8593 --- /dev/null +++ b/lib/include/libv4l2rds.h @@ -0,0 +1,228 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#ifndef __LIBV4L2RDS +#define __LIBV4L2RDS + +#include errno.h +#include stdio.h +#include stdlib.h +#include string.h +#include stdbool.h +#include unistd.h +#include stdint.h +#include time.h +#include sys/types.h +#include sys/mman.h +#include config.h + +#include linux/videodev2.h + +#ifdef __cplusplus +extern C { +#endif /* __cplusplus */ + +#if HAVE_VISIBILITY +#define LIBV4L_PUBLIC __attribute__ ((visibility(default))) +#else +#define LIBV4L_PUBLIC +#endif + +/* used to define the current version (version field) of the v4l2_rds struct */ +#define V4L2_RDS_VERSION (1) + +/* Constants used to define the size of arrays used to store RDS information */ +#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these +* 32 distinct groups, 18 can be used for ODA purposes */ +#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined +* AF Method B does not impose a limit on the number of AFs +* but it is not fully supported at the moment and will +* not receive more than 25 AFs */ + +/* Define Constants for the possible types of RDS information + * used to address the relevant bit in the valid_fields bitmask */ +#define V4L2_RDS_PI0x01/* Program Identification */ +#define V4L2_RDS_PTY 0x02/* Program Type */ +#define V4L2_RDS_TP0x04/* Traffic Program */ +#define V4L2_RDS_PS0x08/* Program Service Name */ +#define V4L2_RDS_TA0x10/* Traffic Announcement */ +#define V4L2_RDS_DI0x20/* Decoder Information */ +#define V4L2_RDS_MS0x40
Re: [RFC PATCH 0/2] Add support for RDS decoding
thank you for the info, it's working now (I went for the include solution) -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 1/2] Initial version of the RDS-decoder library Signed-off-by: Konke Radlow krad...@cisco.com
Hello Hans, no need to thank me for working on it. First of all I do it as a part of a summerjob, and more importantly I quite enjoy it and intend to stay a active member of the development process after my time at Cisco is over. Thank you for your comments. Most fields in this struct (and in the other structs for that matter) could do with some more documentation. I added a lot of short comments explaining the meaning of the fields, and extended the explanation part that comes before each struct definition. + /** RDS info fields **/ + bool is_rbds; /* use RBDS standard version of LUTs */ + uint16_t pi; + uint8_t ps[8]; Looking at rds-ctl, this contains a string, please make it 9 bytes and always 0 terminate it! I also notice in rds-ctl that you filter the chars for being valid ascii and if not replace them with a space. Does the spec say anything about the encoding used for this string? Could we maybe convert it to UTF-8 inside the library so that apps can just consume the string? The character encoding complies with ISO/IEC 10646, so it basically already is UTF-8, and the data could be stored in a wchar_t array without conversion. Is that preferred over uint8_t? +/* adds a raw RDS block to decode it into RDS groups + * @return:bitmask with with updated fields set to 1 + * @rds_data: 3 bytes of raw RDS data, obtained by calling read() + * on RDS capable V4L2 devices */ +LIBV4L_PUBLIC uint32_t v4l2_rds_add(struct v4l2_rds *handle, struct v4l2_rds_data *rds_data); Unless I'm missing something, you are no defining struct v4l2_rds_data anywhere, why not just make this a uint8_t ? The v4l2_rds_data structure is defined by v4l in the videodev2.h header, and is returned when calling the read function on a rds capable device On Saturday, July 28, 2012 11:08:24 AM Hans de Goede wrote: Hi, First of all many thanks for working on this! Note I've also taken a quick look at the original patch with the actual implementation and that looks good. I'm replying here because in my mind the API is the most interesting thing to discuss. Comments inline. On 07/26/2012 06:21 PM, Konke Radlow wrote: PATCH 1/2 was missing the public header for the rds library. I'm sorry for that mistake: diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h new file mode 100644 index 000..04843d3 --- /dev/null +++ b/lib/include/libv4l2rds.h @@ -0,0 +1,203 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#ifndef __LIBV4L2RDS +#define __LIBV4L2RDS + +#include errno.h +#include stdio.h +#include stdlib.h +#include string.h +#include stdbool.h +#include unistd.h +#include stdint.h +#include sys/types.h +#include sys/mman.h + +#include linux/videodev2.h + +#ifdef __cplusplus +extern C { +#endif /* __cplusplus */ + +#if __GNUC__ = 4 +#define LIBV4L_PUBLIC __attribute__ ((visibility(default))) +#else +#define LIBV4L_PUBLIC +#endif + +/* used to define the current version (version field) of the v4l2_rds struct */ +#define V4L2_RDS_VERSION (1) + +/* Constants used to define the size of arrays used to store RDS information */ +#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these + * 32 distinct groups, 18 can be used for ODA purposes*/ +#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined +* AF Method B does not impose a limit on the number of AFs +* but it is not fully supported at the moment and will +* not receive more than 25 AFs */ + +/* Define Constants for the possible types of RDS information + * used to address the relevant bit in the valid_bitmask */ +#define V4L2_RDS_PI0x01/* Program Identification */ +#define V4L2_RDS_PTY 0x02/* Program Type */ +#define V4L2_RDS_TP0x04/* Traffic Program */ +#define V4L2_RDS_PS0x08/* Program
Re: [RFC PATCH 1/2] Initial version of the RDS-decoder library Signed-off-by: Konke Radlow krad...@cisco.com
Hello Hans, no need to thank me for working on it. First of all I do it as a part of a summerjob, and more importantly I quite enjoy it and intend to stay a active member of the development process after my time at Cisco is over. Thank you for your comments. Most fields in this struct (and in the other structs for that matter) could do with some more documentation. I added a lot of short comments explaining the meaning of the fields, and extended the explanation part that comes before each struct definition. + /** RDS info fields **/ + bool is_rbds; /* use RBDS standard version of LUTs */ + uint16_t pi; + uint8_t ps[8]; Looking at rds-ctl, this contains a string, please make it 9 bytes and always 0 terminate it! I also notice in rds-ctl that you filter the chars for being valid ascii and if not replace them with a space. Does the spec say anything about the encoding used for this string? Could we maybe convert it to UTF-8 inside the library so that apps can just consume the string? The character encoding complies with ISO/IEC 10646, so it basically already is UTF-8, and the data could be stored in a wchar_t array without conversion. Is that preferred over uint8_t? +/* adds a raw RDS block to decode it into RDS groups + * @return:bitmask with with updated fields set to 1 + * @rds_data: 3 bytes of raw RDS data, obtained by calling read() + * on RDS capable V4L2 devices */ +LIBV4L_PUBLIC uint32_t v4l2_rds_add(struct v4l2_rds *handle, struct v4l2_rds_data *rds_data); Unless I'm missing something, you are no defining struct v4l2_rds_data anywhere, why not just make this a uint8_t ? The v4l2_rds_data structure is defined by v4l in the videodev2.h header, and is returned when calling the read function on a rds capable device source: http://hverkuil.home.xs4all.nl/spec/media.html#v4l2-rds-data Maybe I didn't get you point though? greetings, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 0/2] Add support for RDS decoding
Yes, I realized too late that the library header file was missing from the submitted patch. I created a additional patch and attached it to the [RFC PATCH 1/2] thread. I updated the repository. It should now be based on the most recent version of the tree (I used git://git.linuxtv.org/v4l-utils.git as the origin) changing the condition in the library header from #if __GNUC__ = 4 #define LIBV4L_PUBLIC __attribute__ ((visibility(default))) #else #define LIBV4L_PUBLIC #endif to #if HAVE_VISIBILITY #define LIBV4L_PUBLIC __attribute__ ((visibility(default))) #else #define LIBV4L_PUBLIC #endif causes linker problems for me. The public library functions can no longer be found. I cannot figure out why it's working for programs using libv4l2.la but not for programs using libv4l2rds.la greetings, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 1/2] Initial version of the RDS-decoder library Signed-off-by: Konke Radlow krad...@cisco.com
PATCH 1/2 was missing the public header for the rds library. I'm sorry for that mistake: diff --git a/lib/include/libv4l2rds.h b/lib/include/libv4l2rds.h new file mode 100644 index 000..04843d3 --- /dev/null +++ b/lib/include/libv4l2rds.h @@ -0,0 +1,203 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#ifndef __LIBV4L2RDS +#define __LIBV4L2RDS + +#include errno.h +#include stdio.h +#include stdlib.h +#include string.h +#include stdbool.h +#include unistd.h +#include stdint.h +#include sys/types.h +#include sys/mman.h + +#include linux/videodev2.h + +#ifdef __cplusplus +extern C { +#endif /* __cplusplus */ + +#if __GNUC__ = 4 +#define LIBV4L_PUBLIC __attribute__ ((visibility(default))) +#else +#define LIBV4L_PUBLIC +#endif + +/* used to define the current version (version field) of the v4l2_rds struct */ +#define V4L2_RDS_VERSION (1) + +/* Constants used to define the size of arrays used to store RDS information */ +#define MAX_ODA_CNT 18 /* there are 16 groups each with type a or b. Of these +* 32 distinct groups, 18 can be used for ODA purposes*/ +#define MAX_AF_CNT 25 /* AF Method A allows a maximum of 25 AFs to be defined +* AF Method B does not impose a limit on the number of AFs +* but it is not fully supported at the moment and will +* not receive more than 25 AFs */ + +/* Define Constants for the possible types of RDS information + * used to address the relevant bit in the valid_bitmask */ +#define V4L2_RDS_PI0x01/* Program Identification */ +#define V4L2_RDS_PTY 0x02/* Program Type */ +#define V4L2_RDS_TP0x04/* Traffic Program */ +#define V4L2_RDS_PS0x08/* Program Service Name */ +#define V4L2_RDS_TA0x10/* Traffic Announcement */ +#define V4L2_RDS_DI0x20/* Decoder Information */ +#define V4L2_RDS_MS0x40/* Music / Speech code */ +#define V4L2_RDS_PTYN 0x80/* Program Type Name */ +#define V4L2_RDS_RT0x100 /* Radio-Text */ +#define V4L2_RDS_TIME 0x200 /* Date and Time information */ +#define V4L2_RDS_TMC 0x400 /* TMC availability */ +#define V4L2_RDS_AF0x800 /* AF (alternative freq) available */ +#define V4L2_RDS_ECC 0x1000 /* Extended County Code */ +#define V4L2_RDS_LC0x2000 /* Language Code */ + +/* Define Constants for the state of the RDS decoding process + * used to address the relevant bit in the state_bitmask */ +#define V4L2_RDS_GROUP_NEW 0x01/* New group received */ +#define V4L2_RDS_ODA 0x02/* Open Data Group announced */ + +/* Decoder Information (DI) codes + * used to decode the DI information according to the RDS standard */ +#define V4L2_RDS_FLAG_STEREO 0x01 +#define V4L2_RDS_FLAG_ARTIFICIAL_HEAD 0x02 +#define V4L2_RDS_FLAG_COMPRESSED 0x04 +#define V4L2_RDS_FLAG_STATIC_PTY 0x08 + +/* struct to encapsulate one complete RDS group */ +struct v4l2_rds_group { + uint16_t pi; + char group_version; + bool traffic_prog; + uint8_t group_id; + uint8_t pty; + uint8_t data_b_lsb; + uint8_t data_c_msb; + uint8_t data_c_lsb; + uint8_t data_d_msb; + uint8_t data_d_lsb; +}; + +/* struct to encapsulate some statistical information about the decoding process */ +struct v4l2_rds_statistics { + uint32_t block_cnt; + uint32_t group_cnt; + uint32_t block_error_cnt; + uint32_t group_error_cnt; + uint32_t block_corrected_cnt; + uint32_t group_type_cnt[16]; +}; + +/* struct to encapsulate the definition of one ODA (Open Data Application) type */ +struct v4l2_rds_oda { + uint8_t group_id; + char group_version; + uint16_t aid; /* Application Identification */ +}; + +/* struct to encapsulate an array of all defined ODA types for a channel */ +struct v4l2_rds_oda_set { + uint8_t size; + struct v4l2_rds_oda oda[MAX_ODA_CNT]; +}; + +/* struct to encapsulate an array of all defined Alternative
Re: [RFC PATCH 2/2] Initial version of RDS Control utility Signed-off-by: Konke Radlow krad...@cisco.com
1. +#ifdef HAVE_SYS_KLOG_H +#include sys/klog.h +#endif I'll drop those lines 2. + case OptSetDevice: + strncpy(params.fd_name, optarg, 80); + if (optarg[0] = '0' optarg[0] = '9' optarg[1] == 0) { I didn't know about the isalpha function, thanks for the hint 3. + if (params.options[OptPrintBlock]) + updated_fields = 0x; will use that handy definition (UINT32_MAX ) 4. + int opt = 0; + char short_options[26 * 2 * 2 + 1]; the number 26 was taken over from the code of the v4l2-ctl tool. I don't know where that magic number is coming from. I just checked the v4l2-ctl code again and there seem to be 26 short options defined in the enum Option type. Thank you for your comments so far. I'll incorporate them tomorrow morning when I'm back on my working machine, regards, Konke On Thu, Jul 26, 2012 at 9:13 PM, Gregor Jasny gja...@googlemail.com wrote: On 7/25/12 7:44 PM, Konke Radlow wrote: +static void print_rds_af(struct v4l2_rds_af_set *af_set) +{ + int counter = 0; + + printf(\nAnnounced AFs: %u, af_set-announced_af); + for (int i = 0; i af_set-size i af_set-announced_af; i++, counter++) { + if (af_set-af[i] = 8750 ) { + printf(\nAF%02d: %.1fMHz, counter, af_set-af[i] / 100.0); + continue; + } + printf(\nAF%02d: %.1fkHz, counter, af_set-af[i] / 1000.0); + } +} + +static void print_rds_pi(const struct v4l2_rds *handle) +{ + printf(\nArea Coverage: %s, v4l2_rds_get_coverage_str(handle)); +} + +static void print_rds_data(struct v4l2_rds *handle, uint32_t updated_fields) +{ + if (params.options[OptPrintBlock]) + updated_fields = 0x; You could use UINT32_MAX here + + if (updated_fields V4L2_RDS_PI + handle-valid_fields V4L2_RDS_PI) { + printf(\nPI: %04x, handle-pi); + print_rds_pi(handle); + } +static int parse_cl(int argc, char **argv) +{ + int i = 0; + int idx = 0; + int opt = 0; + char short_options[26 * 2 * 2 + 1]; Where comes the 26 and 2 from? Could this be (ARRAY_SIZE(long_options) + 1 ) * 2? -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH 1/2] Initial version of the RDS-decoder library Signed-off-by: Konke Radlow krad...@cisco.com
--- Makefile.am |3 +- configure.ac| 10 +- lib/libv4l2rds/Makefile.am | 11 + lib/libv4l2rds/libv4l2rds.c | 871 +++ lib/libv4l2rds/libv4l2rds.pc.in | 11 + 5 files changed, 904 insertions(+), 2 deletions(-) create mode 100644 lib/libv4l2rds/Makefile.am create mode 100644 lib/libv4l2rds/libv4l2rds.c create mode 100644 lib/libv4l2rds/libv4l2rds.pc.in diff --git a/Makefile.am b/Makefile.am index b7b356c..6707f5f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,8 @@ SUBDIRS = \ lib/libv4lconvert \ lib/libv4l2 \ lib/libv4l1 \ - lib/libdvbv5 + lib/libdvbv5 \ + lib/libv4l2rds if WITH_V4LUTILS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index 8ddcc9d..1d7eb29 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l2/Makefile lib/libv4l1/Makefile lib/libdvbv5/Makefile + lib/libv4l2rds/Makefile utils/libv4l2util/Makefile utils/libmedia_dev/Makefile @@ -36,6 +37,7 @@ AC_CONFIG_FILES([Makefile lib/libv4l1/libv4l1.pc lib/libv4l2/libv4l2.pc lib/libdvbv5/libdvbv5.pc + lib/libv4l2rds/libv4l2rds.pc ]) AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-bzip2 -Wno-portability]) # 1.10 is needed for target_LIBTOOLFLAGS @@ -146,13 +148,17 @@ AC_ARG_WITH(libv4l2subdir, AS_HELP_STRING(--with-libv4l2subdir=DIR,set libv4l2 l AC_ARG_WITH(libv4lconvertsubdir, AS_HELP_STRING(--with-libv4lconvertsubdir=DIR,set libv4lconvert library subdir [default=libv4l]), libv4lconvertsubdir=$withval, libv4lconvertsubdir=libv4l) +AC_ARG_WITH(libv4l2rdssubdir, AS_HELP_STRING(--with-libv4l2rdssubdir=DIR,set libv4l2rds library subdir [default=libv4l]), + libv4l2rdssubdir=$withval, libv4l2rdssubdir=libv4l) + AC_ARG_WITH(udevdir, AS_HELP_STRING(--with-udevdir=DIR,set udev directory [default=/lib/udev]), udevdir=$withval, udevdir=/lib/udev) - + libv4l1privdir=$libdir/$libv4l1subdir libv4l2privdir=$libdir/$libv4l2subdir libv4l2plugindir=$libv4l2privdir/plugins libv4lconvertprivdir=$libdir/$libv4lconvertsubdir +libv4l2rdsprivdir=$libdir/$libv4l2rdssubdir keytablesystemdir=$udevdir/rc_keymaps keytableuserdir=$sysconfdir/rc_keymaps @@ -166,6 +172,7 @@ AC_SUBST(libv4lconvertprivdir) AC_SUBST(keytablesystemdir) AC_SUBST(keytableuserdir) AC_SUBST(udevrulesdir) +AC_SUBST(libv4l2rdsprivdir) AC_SUBST(pkgconfigdir) AC_DEFINE_UNQUOTED([V4L_UTILS_VERSION], [$PACKAGE_VERSION], [v4l-utils version string]) @@ -173,6 +180,7 @@ AC_DEFINE_DIR([LIBV4L1_PRIV_DIR], [libv4l1privdir], [libv4l1 private lib directo AC_DEFINE_DIR([LIBV4L2_PRIV_DIR], [libv4l2privdir], [libv4l2 private lib directory]) AC_DEFINE_DIR([LIBV4L2_PLUGIN_DIR], [libv4l2plugindir], [libv4l2 plugin directory]) AC_DEFINE_DIR([LIBV4LCONVERT_PRIV_DIR], [libv4lconvertprivdir], [libv4lconvert private lib directory]) +AC_DEFINE_DIR([LIBV4L2RDS_PRIV_DIR], [libv4l2rdsprivdir], [libv4l2rds private lib directory]) AC_DEFINE_DIR([IR_KEYTABLE_SYSTEM_DIR], [keytablesystemdir], [ir-keytable preinstalled tables directory]) AC_DEFINE_DIR([IR_KEYTABLE_USER_DIR], [keytableuserdir], [ir-keytable user defined tables directory]) diff --git a/lib/libv4l2rds/Makefile.am b/lib/libv4l2rds/Makefile.am new file mode 100644 index 000..5796890 --- /dev/null +++ b/lib/libv4l2rds/Makefile.am @@ -0,0 +1,11 @@ +if WITH_LIBV4L +lib_LTLIBRARIES = libv4l2rds.la +include_HEADERS = ../include/libv4l2rds.h +pkgconfig_DATA = libv4l2rds.pc +else +noinst_LTLIBRARIES = libv4l2rds.la +endif + +libv4l2rds_la_SOURCES = libv4l2rds.c +libv4l2rds_la_CPPFLAGS = -fvisibility=hidden $(ENFORCE_LIBV4L_STATIC) -std=c99 +libv4l2rds_la_LDFLAGS = -version-info 0 -lpthread $(DLOPEN_LIBS) $(ENFORCE_LIBV4L_STATIC) diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c new file mode 100644 index 000..0bacaa2 --- /dev/null +++ b/lib/libv4l2rds/libv4l2rds.c @@ -0,0 +1,871 @@ +/* + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#include linux/videodev2.h + +#include ../include/libv4l2rds.h + +/* struct
[RFC PATCH 2/2] Initial version of RDS Control utility Signed-off-by: Konke Radlow krad...@cisco.com
--- Makefile.am |3 +- configure.ac |1 + utils/rds-ctl/Makefile.am |5 + utils/rds-ctl/rds-ctl.cpp | 978 + 4 files changed, 986 insertions(+), 1 deletion(-) create mode 100644 utils/rds-ctl/Makefile.am create mode 100644 utils/rds-ctl/rds-ctl.cpp diff --git a/Makefile.am b/Makefile.am index 6707f5f..47103a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,8 @@ SUBDIRS += \ utils/v4l2-compliance \ utils/v4l2-ctl \ utils/v4l2-dbg \ - utils/v4l2-sysfs-path + utils/v4l2-sysfs-path \ + utils/rds-ctl if LINUX_OS SUBDIRS += \ diff --git a/configure.ac b/configure.ac index 1d7eb29..1ad99e6 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_CONFIG_FILES([Makefile utils/v4l2-sysfs-path/Makefile utils/xc3028-firmware/Makefile utils/qv4l2/Makefile + utils/rds-ctl/Makefile contrib/freebsd/Makefile contrib/test/Makefile diff --git a/utils/rds-ctl/Makefile.am b/utils/rds-ctl/Makefile.am new file mode 100644 index 000..9a84257 --- /dev/null +++ b/utils/rds-ctl/Makefile.am @@ -0,0 +1,5 @@ +bin_PROGRAMS = rds-ctl + +rds_ctl_SOURCES = rds-ctl.cpp +rds_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4l2rds/libv4l2rds.la + diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp new file mode 100644 index 000..8ddb969 --- /dev/null +++ b/utils/rds-ctl/rds-ctl.cpp @@ -0,0 +1,978 @@ +/* + * rds-ctl.cpp is based on v4l2-ctl.cpp + * + * the following applies for all RDS related parts: + * Copyright 2012 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * Author: Konke Radlow korad...@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + */ + +#include unistd.h +#include stdlib.h +#include stdio.h +#include string.h +#include wchar.h +#include locale.h +#include inttypes.h +#include getopt.h +#include sys/types.h +#include fcntl.h +#include errno.h +#include sys/ioctl.h +#include sys/time.h +#include dirent.h +#include config.h +#include signal.h + +#ifdef HAVE_SYS_KLOG_H +#include sys/klog.h +#endif + +#include linux/videodev2.h +#include libv4l2.h +#include libv4l2rds.h + +#include list +#include vector +#include map +#include string +#include algorithm + +#define ARRAY_SIZE(arr) ((int)(sizeof(arr) / sizeof((arr)[0]))) + +typedef std::vectorstd::string dev_vec; +typedef std::mapstd::string, std::string dev_map; + +/* Short option list + + Please keep in alphabetical order. + That makes it easier to see which short options are still free. + + In general the lower case is used to set something and the upper + case is used to retrieve a setting. */ +enum Option { + OptSetDevice = 'd', + OptGetDriverInfo = 'D', + OptGetFreq = 'F', + OptSetFreq = 'f', + OptHelp = 'h', + OptReadRds = 'R', + OptGetTuner = 'T', + OptSetTuner = 't', + OptUseWrapper = 'w', + OptAll = 128, + OptFreqSeek, + OptListDevices, + OptOpenFile, + OptPrintBlock, + OptSilent, + OptTunerIndex, + OptVerbose, + OptWaitLimit, + OptLast = 256 +}; + +struct ctl_parameters { + bool terminate_decoding; + char options[OptLast]; + char fd_name[80]; + bool filemode_active; + double freq; + uint32_t wait_limit; + uint8_t tuner_index; + struct v4l2_hw_freq_seek freq_seek; +}; + +static struct ctl_parameters params; +static int app_result; + +static struct option long_options[] = { + {all, no_argument, 0, OptAll}, + {device, required_argument, 0, OptSetDevice}, + {file, required_argument, 0, OptOpenFile}, + {freq-seek, required_argument, 0, OptFreqSeek}, + {get-freq, no_argument, 0, OptGetFreq}, + {get-tuner, no_argument, 0, OptGetTuner}, + {help, no_argument, 0, OptHelp}, + {info, no_argument, 0, OptGetDriverInfo}, + {list-devices, no_argument, 0, OptListDevices}, + {print-block, no_argument, 0, OptPrintBlock}, + {read-rds, no_argument, 0, OptReadRds}, + {set-freq, required_argument, 0, OptSetFreq}, + {tuner-index, required_argument, 0, OptTunerIndex}, + {verbose, no_argument, 0, OptVerbose
[RFC PATCH 0/2] Add support for RDS decoding
Hello, Over the last couple of weeks I have been working on a library that adds RDS decoding support to the v4l-utils repository. It currently supports the core RDS standard but no advanced features yet like ODA (TMC). I also wrote a control application that can be used to test the library with any RDS-capable v4l device. This application is based on the v4l2-ctl tool and many of the basic options have been taken over to ease the usage. By default the tool will print all RDS fields that it was able to decode to the std output. The latest version of the code can always be found in my github repository: https://github.com/koradlow/v4l2-rds-ctl You can also find a tool that was created to generate test RDS data with the pcimax-3000+ card under Linux there. This program is functional, but still a early version, and the functionality will be improved in the future: https://github.com/koradlow/pcimax-ctl Upcoming: TMC support (Traffic Message Channel) This work is being done as part of a summerjob I`m doing at Cisco Systems Norway with Hans Verkuil as my mentor. Comments and remarks are very welcome. Regards, Konke -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html