Re: [RFC PATCH] Add core TMC (Traffic Message Channel) support

2012-08-12 Thread Hans de Goede

Hi,

Looks good to me.

Regards,

Hans


On 08/10/2012 07:04 PM, Konke Radlow wrote:

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_AF   0x800   /* AF (alternative freq) available */
  #define V4L2_RDS_ECC  0x1000  /* Extended County Code */
  #define V4L2_RDS_LC   0x2000  /* 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 

Re: [RFC PATCH] Add core TMC (Traffic Message Channel) support

2012-08-12 Thread Hans Verkuil
On Fri August 10 2012 19:04:52 Konke Radlow wrote:
 
 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_AF  0x800   /* AF (alternative freq) available */
  #define V4L2_RDS_ECC 0x1000  /* Extended County Code */
  #define V4L2_RDS_LC  0x2000  /* Language Code */
 +#define V4L2_RDS_TMC_SG  0x4000  /* RDS-TMC single group */
 +#define V4L2_RDS_TMC_MG  0x8000  /* 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_GROUP0x04
 +
  /* 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

28 should be a define instead of being hardcoded.

 +  * 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 

[RFC PATCH] Add core TMC (Traffic Message Channel) support

2012-08-10 Thread Konke Radlow

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
+++