libdvbv5: Split libdvbv5 properties from stats
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 5 Sep 2014 13:37:24 +0000 (10:37 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 5 Sep 2014 18:18:19 +0000 (15:18 -0300)
As newer needs are added to the library, we want to be able
to add new commands and new stats independently.

So, we need to split the properties into two different ranges,
or otherwise a new libdvbv5 command property would break
userspace, by renumbering the statistics.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/include/libdvbv5/dvb-v5-std.h
lib/libdvbv5/dvb-fe.c
lib/libdvbv5/dvb-v5-std.c

index e99cb9d..52ae891 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 - Mauro Carvalho Chehab
+ * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -56,22 +56,7 @@ extern const void *dvb_v5_attr_names[];
 
 #define DTV_MAX_USER_COMMAND    DTV_FREQ_BPF
 
-/* For status and statistics */
-
-#define DTV_STATUS              (DTV_MAX_USER_COMMAND + 1)
-#define DTV_BER                 (DTV_MAX_USER_COMMAND + 2)
-#define DTV_PER                 (DTV_MAX_USER_COMMAND + 3)
-#define DTV_QUALITY             (DTV_MAX_USER_COMMAND + 4)
-#define DTV_PRE_BER            (DTV_MAX_USER_COMMAND + 5)
-
-#define DTV_MAX_STAT_COMMAND   DTV_PRE_BER
-
-#define DTV_USER_NAME_SIZE     (1 + DTV_MAX_STAT_COMMAND - DTV_USER_COMMAND_START)
-
-/* There are currently 8 stats provided on Kernelspace */
-#define DTV_NUM_KERNEL_STATS   8
-
-#define DTV_NUM_STATS_PROPS    (DTV_NUM_KERNEL_STATS + DTV_MAX_STAT_COMMAND - DTV_MAX_USER_COMMAND)
+#define DTV_USER_NAME_SIZE     (1 + DTV_MAX_USER_COMMAND - DTV_USER_COMMAND_START)
 
 enum dvb_sat_polarization {
        POLARIZATION_OFF        = 0,
@@ -81,6 +66,23 @@ enum dvb_sat_polarization {
        POLARIZATION_R          = 4,
 };
 
+#define DTV_STAT_COMMAND_START 512
+
+#define DTV_STATUS              (DTV_STAT_COMMAND_START + 0)
+#define DTV_BER                 (DTV_STAT_COMMAND_START + 1)
+#define DTV_PER                 (DTV_STAT_COMMAND_START + 2)
+#define DTV_QUALITY             (DTV_STAT_COMMAND_START + 3)
+#define DTV_PRE_BER            (DTV_STAT_COMMAND_START + 4)
+
+#define DTV_MAX_STAT_COMMAND   DTV_PRE_BER
+
+#define DTV_STAT_NAME_SIZE     (1 + DTV_MAX_STAT_COMMAND - DTV_STAT_COMMAND_START)
+
+/* There are currently 8 stats provided on Kernelspace */
+#define DTV_NUM_KERNEL_STATS   8
+
+#define DTV_NUM_STATS_PROPS    (DTV_NUM_KERNEL_STATS + DTV_STAT_NAME_SIZE)
+
 enum dvb_quality {
        DVB_QUAL_UNKNOWN = 0,
        DVB_QUAL_POOR,
@@ -89,7 +91,8 @@ enum dvb_quality {
 };
 
 extern const char *dvb_sat_pol_name[6];
-extern const char *dvb_user_name[DTV_USER_NAME_SIZE];
+extern const char *dvb_user_name[DTV_USER_NAME_SIZE + 1];
+extern const char *dvb_stat_name[DTV_STAT_NAME_SIZE + 1];
 extern const void *dvb_user_attr_names[];
 
 #endif
index 29ef148..61a9dce 100644 (file)
@@ -459,8 +459,10 @@ const char *dvb_cmd_name(int cmd)
 {
        if (cmd >= 0 && cmd < ARRAY_SIZE(dvb_v5_name))
                return dvb_v5_name[cmd];
-       else if (cmd >= DTV_USER_COMMAND_START && cmd <= DTV_MAX_STAT_COMMAND)
+       else if (cmd >= DTV_USER_COMMAND_START && cmd <= DTV_MAX_USER_COMMAND)
                return dvb_user_name[cmd - DTV_USER_COMMAND_START];
+       else if (cmd >= DTV_STAT_COMMAND_START && cmd <= DTV_MAX_STAT_COMMAND)
+               return dvb_stat_name[cmd - DTV_STAT_COMMAND_START];
        return NULL;
 }
 
index f7209c3..834dc19 100644 (file)
@@ -216,7 +216,7 @@ const char *dvb_sat_pol_name[6] = {
        [5] = NULL,
 };
 
-const char *dvb_user_name[DTV_USER_NAME_SIZE] = {
+const char *dvb_user_name[DTV_USER_NAME_SIZE + 1] = {
        [DTV_POLARIZATION - DTV_USER_COMMAND_START] =   "POLARIZATION",
        [DTV_VIDEO_PID - DTV_USER_COMMAND_START] =      "VIDEO PID",
        [DTV_AUDIO_PID - DTV_USER_COMMAND_START] =      "AUDIO PID",
@@ -227,17 +227,20 @@ const char *dvb_user_name[DTV_USER_NAME_SIZE] = {
        [DTV_DISEQC_WAIT - DTV_USER_COMMAND_START] =    "DISEQC WAIT",
        [DTV_DISEQC_LNB - DTV_USER_COMMAND_START] =     "DISEQC LNB",
        [DTV_FREQ_BPF - DTV_USER_COMMAND_START] =       "FREQ BPF",
-       [DTV_STATUS - DTV_USER_COMMAND_START] =         "STATUS",
-       [DTV_BER - DTV_USER_COMMAND_START] =            "POST BER",
-       [DTV_PER - DTV_USER_COMMAND_START] =            "PER",
-       [DTV_QUALITY - DTV_USER_COMMAND_START] =        "QUALITY",
-       [DTV_PRE_BER - DTV_USER_COMMAND_START] =        "PRE BER",
+       [DTV_USER_NAME_SIZE] = NULL,
+};
 
-       [DTV_USER_NAME_SIZE - 1] = NULL,
+const char *dvb_stat_name[DTV_STAT_NAME_SIZE + 1] = {
+       [DTV_STATUS - DTV_STAT_COMMAND_START] =         "STATUS",
+       [DTV_BER - DTV_STAT_COMMAND_START] =            "POST BER",
+       [DTV_PER - DTV_STAT_COMMAND_START] =            "PER",
+       [DTV_QUALITY - DTV_STAT_COMMAND_START] =        "QUALITY",
+       [DTV_PRE_BER - DTV_STAT_COMMAND_START] =        "PRE BER",
+       [DTV_STAT_NAME_SIZE] = NULL,
 };
 
-const void *dvb_user_attr_names[] = {
-       [0 ... DTV_MAX_STAT_COMMAND - DTV_USER_COMMAND_START] = NULL,
+const void *dvb_user_attr_names[DTV_USER_NAME_SIZE + 1] = {
+       [0 ... DTV_USER_NAME_SIZE] = NULL,
        [DTV_POLARIZATION - DTV_USER_COMMAND_START]           = dvb_sat_pol_name,
 };