From 4e4bb6acc9d2cbb8fc1392aff3bafc47e3cb0464 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 5 Sep 2014 10:37:24 -0300 Subject: [PATCH] libdvbv5: Split libdvbv5 properties from stats 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 --- lib/include/libdvbv5/dvb-v5-std.h | 39 +++++++++++++++++++++------------------ lib/libdvbv5/dvb-fe.c | 4 +++- lib/libdvbv5/dvb-v5-std.c | 21 ++++++++++++--------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/lib/include/libdvbv5/dvb-v5-std.h b/lib/include/libdvbv5/dvb-v5-std.h index e99cb9d..52ae891 100644 --- a/lib/include/libdvbv5/dvb-v5-std.h +++ b/lib/include/libdvbv5/dvb-v5-std.h @@ -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 diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c index 29ef148..61a9dce 100644 --- a/lib/libdvbv5/dvb-fe.c +++ b/lib/libdvbv5/dvb-fe.c @@ -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; } diff --git a/lib/libdvbv5/dvb-v5-std.c b/lib/libdvbv5/dvb-v5-std.c index f7209c3..834dc19 100644 --- a/lib/libdvbv5/dvb-v5-std.c +++ b/lib/libdvbv5/dvb-v5-std.c @@ -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, }; -- 2.7.4