Skip to contentSkip to conversation

renamings and librarization

PATCH New André Roth 1 participant 2 messages May 16, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 renamings and librarization

---
 lib/include/dvb-fe.h           |    4 ++--
 lib/include/dvb-file.h         |   12 ++++++++++--
 lib/include/dvb-frontend.h     |    2 +-
 lib/include/libsat.h           |   22 ++++++++++++++++------
 lib/libdvbv5/dvb-file.c        |    2 +-
 lib/libdvbv5/libsat.c          |   20 +++++++++++++++-----
 utils/dvb/dvb-format-convert.c |    2 +-
 utils/dvb/dvbv5-scan.c         |    8 ++++----
 utils/dvb/dvbv5-zap.c          |    2 +-
 9 files changed, 51 insertions(+), 23 deletions(-)
lib/include/dvb-fe.h +2 -2
index 5179c97..fbb5ff0 100644
@@ -76,12 +76,12 @@ struct dvb_v5_fe_parms {
 	struct dvb_v5_stats		stats;
 
 	/* Satellite specific stuff, specified by the library client */
-	struct dvb_satellite_lnb	*lnb;
+	struct dvbsat_lnb       	*lnb;
 	int				sat_number;
 	unsigned			freq_bpf;
 
 	/* Satellite specific stuff, used internally */
-	enum polarization		pol;
+	enum dvbsat_polarization        pol;
 	int				high_band;
 	unsigned			diseqc_wait;
 	unsigned			freq_offset;
lib/include/dvb-file.h +10 -2
index ec4cdff..b86d4bf 100644
@@ -35,7 +35,7 @@ struct dvb_entry {
 
 	char *location;
 
-	enum polarization pol;
+	enum dvbsat_polarization pol;
 	int sat_number;
 	unsigned freq_bpf;
 	unsigned diseqc_wait;
@@ -92,6 +92,10 @@ enum file_formats {
 
 struct dvb_descriptors;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 static inline void dvb_file_free(struct dvb_file *dvb_file)
 {
 	struct dvb_entry *entry = dvb_file->first_entry, *next;
@@ -146,7 +150,7 @@ int store_dvb_channel(struct dvb_file **dvb_file,
 		      int get_detected, int get_nit);
 int parse_delsys(const char *name);
 enum file_formats parse_format(const char *name);
-struct dvb_file *read_file_format(const char *fname,
+struct dvb_file *dvb_read_file_format(const char *fname,
 					   uint32_t delsys,
 					   enum file_formats format);
 int write_file_format(const char *fname,
@@ -154,4 +158,8 @@ int write_file_format(const char *fname,
 		      uint32_t delsys,
 		      enum file_formats format);
 
+#ifdef __cplusplus
+}
 #endif
+
+#endif // _DVB_FILE_H
lib/include/dvb-frontend.h +1 -1
index 7e7cb64..3ccaf24 100644
@@ -328,7 +328,7 @@ typedef enum fe_pilot {
 	PILOT_AUTO,
 } fe_pilot_t;
 
-typedef enum fe_rolloff {
+typedef enum fe_rolloff { // FIXME: move to libsat.h ?
 	ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
 	ROLLOFF_20,
 	ROLLOFF_25,
lib/include/libsat.h +16 -6
index 1cf4af8..42530ff 100644
@@ -19,7 +19,7 @@
 #ifndef _LIBSAT_H
 #define _LIBSAT_H
 
-enum polarization {
+enum dvbsat_polarization {
 	POLARIZATION_OFF	= 0,
 	POLARIZATION_H		= 1,
 	POLARIZATION_V		= 2,
@@ -27,28 +27,38 @@ enum polarization {
 	POLARIZATION_R		= 4,
 };
 
-struct dvb_satellite_freqrange {
+struct dvbsat_freqrange {
 	unsigned low, high;
 };
 
-struct dvb_satellite_lnb {
+struct dvbsat_lnb {
 	char *name;
 	char *alias;
 	unsigned lowfreq, highfreq;
 
 	unsigned rangeswitch;
 
-	struct dvb_satellite_freqrange freqrange[2];
+	struct dvbsat_freqrange freqrange[2];
 };
 
-struct dvb_v5_fe_parms *parms;
+struct dvb_v5_fe_parms;
+
+extern const char *dvbsat_polarization_name[5];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* From libsat.c */
 int search_lnb(char *name);
 int print_lnb(int i);
 void print_all_lnb(void);
-struct dvb_satellite_lnb *get_lnb(int i);
+struct dvbsat_lnb *get_lnb(int i);
 int dvb_satellite_set_parms(struct dvb_v5_fe_parms *parms);
 int dvb_satellite_get_parms(struct dvb_v5_fe_parms *parms);
 
+#ifdef __cplusplus
+}
 #endif
+
+#endif // _LIBSAT_H
lib/libdvbv5/dvb-file.c +1 -1
index e1f2195..b54c049 100644
@@ -1077,7 +1077,7 @@ int parse_delsys(const char *name)
 	return -1;
 }
 
-struct dvb_file *read_file_format(const char *fname,
+struct dvb_file *dvb_read_file_format(const char *fname,
 				  uint32_t delsys,
 				  enum file_formats format)
 {
lib/libdvbv5/libsat.c +15 -5
index d155686..253e92e 100644
@@ -24,7 +24,7 @@
 
 #include "dvb-fe.h"
 
-struct dvb_satellite_lnb lnb[] = {
+struct dvbsat_lnb lnb[] = {
 	{
 		.name = "Europe",
 		.alias = "UNIVERSAL",
@@ -130,7 +130,7 @@ void print_all_lnb(void)
 	}
 }
 
-struct dvb_satellite_lnb *get_lnb(int i)
+struct dvbsat_lnb *get_lnb(int i)
 {
 	if (i >= ARRAY_SIZE(lnb))
 		return NULL;
@@ -212,6 +212,8 @@ static void dvbsat_diseqc_prep_frame_addr(struct diseqc_cmd *cmd,
 	cmd->address = diseqc_addr[type];
 }
 
+struct dvb_v5_fe_parms *parms; // legacy code, used for parms->fd, FIXME anyway
+
 /* Inputs are numbered from 1 to 16, according with the spec */
 static int dvbsat_diseqc_write_to_port_group(struct diseqc_cmd *cmd,
 					     int high_band,
@@ -269,7 +271,7 @@ static int dvbsat_scr_odu_channel_change(struct diseqc_cmd *cmd,
 static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 {
 	int rc;
-        enum polarization pol = parms->pol;
+        enum dvbsat_polarization pol = parms->pol;
 	int pol_v = (pol == POLARIZATION_V) || (pol == POLARIZATION_R);
 	int high_band = parms->high_band;
 	int sat_number = parms->sat_number;
@@ -343,8 +345,8 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 
 int dvb_satellite_set_parms(struct dvb_v5_fe_parms *parms)
 {
-	struct dvb_satellite_lnb *lnb = parms->lnb;
-        enum polarization pol = parms->pol;
+	struct dvbsat_lnb *lnb = parms->lnb;
+        enum dvbsat_polarization pol = parms->pol;
 	uint32_t freq;
 	uint16_t t = 0;
 	uint32_t voltage = SEC_VOLTAGE_13;
@@ -407,3 +409,11 @@ int dvb_satellite_get_parms(struct dvb_v5_fe_parms *parms)
 
 	return 0;
 }
+
+const char *dvbsat_polarization_name[5] = {
+	"OFF",
+	"H",
+	"V",
+	"L",
+	"R",
+};
utils/dvb/dvb-format-convert.c +1 -1
index 799fe8f..6db5219 100644
@@ -79,7 +79,7 @@ static int convert_file(struct arguments *args)
 
 	printf("Reading file %s\n", args->input_file);
 
-	dvb_file = read_file_format(args->input_file, args->delsys,
+	dvb_file = dvb_read_file_format(args->input_file, args->delsys,
 				    args->input_format);
 	if (!dvb_file) {
 		fprintf(stderr, "Error reading file %s\n", args->input_file);
utils/dvb/dvbv5-scan.c +4 -4
index 48e083b..125e285 100644
@@ -130,7 +130,7 @@ static int check_frontend(struct dvb_v5_fe_parms *parms, int timeout)
 static int new_freq_is_needed(struct dvb_entry *entry,
 			      struct dvb_entry *last_entry,
 			      uint32_t freq,
-			      enum polarization pol,
+			      enum dvbsat_polarization pol,
 			      int shift)
 {
 	int i;
@@ -260,7 +260,7 @@ static void add_other_freq_entries(struct dvb_file *dvb_file,
 {
 	int i;
 	uint32_t freq, shift = 0;
-	enum polarization pol = POLARIZATION_OFF;
+	enum dvbsat_polarization pol = POLARIZATION_OFF;
 
 	if (!dvb_desc->nit_table.frequency)
 		return;
@@ -307,7 +307,7 @@ static int run_scan(struct arguments *args,
 		sys = SYS_UNDEFINED;
 		break;
 	}
-	dvb_file = read_file_format(args->confname, sys,
+	dvb_file = dvb_read_file_format(args->confname, sys,
 				    args->input_format);
 	if (!dvb_file)
 		return -2;
@@ -557,7 +557,7 @@ int main(int argc, char **argv)
 	if (verbose)
 		fprintf(stderr, "using demux '%s'\n", args.demux_dev);
 
-	parms = dvb_fe_open(args.adapter, args.frontend, verbose, 0);
+	struct dvb_v5_fe_parms *parms = dvb_fe_open(args.adapter, args.frontend, verbose, 0);
 	if (!parms)
 		return -1;
 	if (lnb >= 0)
utils/dvb/dvbv5-zap.c +1 -1
index c32a6ba..01bf5d9 100644
@@ -128,7 +128,7 @@ static int parse(struct arguments *args,
 		sys = SYS_UNDEFINED;
 		break;
 	}
-	dvb_file = read_file_format(args->confname, sys,
+	dvb_file = dvb_read_file_format(args->confname, sys,
 				    args->input_format);
 	if (!dvb_file)
 		return -2;
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 2/2 refactored for user properties

---
 lib/include/dvb-fe.h                        |    4 +-
 lib/include/dvb-file.h                      |   13 +-
 lib/include/dvb-v5-std.h                    |   70 ++
 lib/include/libsat.h                        |    8 +-
 lib/libdvbv5/Makefile.am                    |    4 +-
 lib/libdvbv5/descriptors.c                  |    1 +
 lib/libdvbv5/dvb-fe.c                       |    2 +-
 lib/libdvbv5/dvb-file.c                     |   93 ++-
 lib/libdvbv5/dvb-legacy-channel-format.c    |    2 +
 lib/libdvbv5/{dvb-v5-std.h => dvb-v5-std.c} |   27 +-
 lib/libdvbv5/dvb-v5.c                       |  230 +++++++
 lib/libdvbv5/dvb-v5.h                       |  245 +-------
 lib/libdvbv5/dvb-zap-format.c               |    1 +
 lib/libdvbv5/dvb_frontend.h                 |  436 +++++++++++++
 lib/libdvbv5/gen_dvb_structs.pl             |  899 ++++++++++++++-------------
 lib/libdvbv5/libsat.c                       |    7 +-
 utils/dvb/dvbv5-scan.c                      |    5 +-
 17 files changed, 1331 insertions(+), 716 deletions(-)
 create mode 100644 lib/include/dvb-v5-std.h
 rename lib/libdvbv5/{dvb-v5-std.h => dvb-v5-std.c} (88%)
 create mode 100644 lib/libdvbv5/dvb-v5.c
 create mode 100644 lib/libdvbv5/dvb_frontend.h
lib/include/dvb-fe.h +2 -2
index fbb5ff0..28350d9 100644
@@ -81,7 +81,7 @@ struct dvb_v5_fe_parms {
 	unsigned			freq_bpf;
 
 	/* Satellite specific stuff, used internally */
-	enum dvbsat_polarization        pol;
+	//enum dvb_sat_polarization       pol;
 	int				high_band;
 	unsigned			diseqc_wait;
 	unsigned			freq_offset;
@@ -164,7 +164,7 @@ int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
 
 extern const unsigned fe_bandwidth_name[8];
 extern const char *dvb_v5_name[46];
-extern const void *dvbv5_attr_names[];
+extern const void *dvb_v5_attr_names[];
 extern const char *delivery_system_name[20];
 
 #endif
lib/include/dvb-file.h +1 -12
index b86d4bf..7a605b3 100644
@@ -35,7 +35,7 @@ struct dvb_entry {
 
 	char *location;
 
-	enum dvbsat_polarization pol;
+//	enum dvbsat_polarization pol;
 	int sat_number;
 	unsigned freq_bpf;
 	unsigned diseqc_wait;
@@ -78,17 +78,6 @@ enum file_formats {
 
 #define PTABLE(a) .table = a, .size=ARRAY_SIZE(a)
 
-/* FAKE DTV codes, for internal usage */
-#define DTV_POLARIZATION        (DTV_MAX_COMMAND + 200)
-#define DTV_VIDEO_PID           (DTV_MAX_COMMAND + 201)
-#define DTV_AUDIO_PID           (DTV_MAX_COMMAND + 202)
-#define DTV_SERVICE_ID          (DTV_MAX_COMMAND + 203)
-#define DTV_CH_NAME             (DTV_MAX_COMMAND + 204)
-#define DTV_VCHANNEL            (DTV_MAX_COMMAND + 205)
-#define DTV_SAT_NUMBER          (DTV_MAX_COMMAND + 206)
-#define DTV_DISEQC_WAIT         (DTV_MAX_COMMAND + 207)
-#define DTV_DISEQC_LNB          (DTV_MAX_COMMAND + 208)
-#define DTV_FREQ_BPF            (DTV_MAX_COMMAND + 209)
 
 struct dvb_descriptors;
 
lib/include/dvb-v5-std.h new file +70 -0

70 lines not on this page · raw message

lib/include/libsat.h +1 -7
index 42530ff..3879914 100644
@@ -19,13 +19,7 @@
 #ifndef _LIBSAT_H
 #define _LIBSAT_H
 
-enum dvbsat_polarization {
-	POLARIZATION_OFF	= 0,
-	POLARIZATION_H		= 1,
-	POLARIZATION_V		= 2,
-	POLARIZATION_L		= 3,
-	POLARIZATION_R		= 4,
-};
+#include "dvb-v5-std.h"
 
 struct dvbsat_freqrange {
 	unsigned low, high;
lib/libdvbv5/Makefile.am +3 -1
index 6f1545d..0a94311 100644
@@ -4,7 +4,9 @@ libdvbv5_la_SOURCES = \
   dvb-demux.c ../include/dvb-demux.h \
   dvb-fe.c ../include/dvb-fe.h \
   dvb-file.c ../include/dvb-file.h \
-  ../include/dvb-frontend.h  dvb-v5.h  dvb-v5-std.h \
+  ../include/dvb-frontend.h \
+  dvb-v5.h dvb-v5.c \
+  ../include/dvb-v5-std.h dvb-v5-std.c \
   dvb-legacy-channel-format.c \
   dvb-zap-format.c \
   descriptors.c descriptors.h \
lib/libdvbv5/descriptors.c +1 -0
index 09e9245..549965a 100644
@@ -26,6 +26,7 @@
 #include "descriptors.h"
 #include "parse_string.h"
 #include "dvb-frontend.h"
+#include "dvb-v5-std.h"
 
 static char *default_charset = "iso-8859-1";
 static char *output_charset = "utf-8";
lib/libdvbv5/dvb-fe.c +1 -1
index 663caa6..91713e2 100644
@@ -385,7 +385,7 @@ void dvb_fe_prt_parms(FILE *fp, const struct dvb_v5_fe_parms *parms)
 	int i;
 
 	for (i = 0; i < parms->n_props; i++) {
-		const char * const *attr_name = dvbv5_attr_names[parms->dvb_prop[i].cmd];
+		const char * const *attr_name = dvb_v5_attr_names[parms->dvb_prop[i].cmd];
 		if (attr_name) {
 			int j;
 
lib/libdvbv5/dvb-file.c +69 -24

175 lines not on this page · raw message

lib/libdvbv5/dvb-legacy-channel-format.c +2 -0
index 53f821b..d05e3d2 100644
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "dvb-file.h"
+#include "dvb-v5-std.h"
 
 /*
  * Standard channel.conf format for DVB-T, DVB-C, DVB-S and ATSC
@@ -97,6 +98,7 @@ static const char *channel_parse_hierarchy[] = {
 };
 
 static const char *channel_parse_polarization[] = {
+	[POLARIZATION_OFF] = "-",
 	[POLARIZATION_H] = "H",
 	[POLARIZATION_V] = "V",
 	[POLARIZATION_L] = "L",
lib/libdvbv5/dvb-v5-std.c renamed from lib/libdvbv5/dvb-v5-std.h +21 -6
similarity index 88%
rename from lib/libdvbv5/dvb-v5-std.h
rename to lib/libdvbv5/dvb-v5-std.c
index 045162c..ec588b1 100644
@@ -19,11 +19,9 @@
  * Per-delivery system properties, according with the specs:
  * 	http://linuxtv.org/downloads/v4l-dvb-apis/FE_GET_SET_PROPERTY.html
  */
-#ifndef _DVB_V5_STD_H
-#define _DVB_V5_STD_H
 
-#include <stddef.h>
-#include "dvb-frontend.h"
+#include "dvb-v5-std.h"
+#include "dvb-v5.h"
 
 const unsigned int sys_dvbt_props[] = {
 	DTV_FREQUENCY,
@@ -166,7 +164,7 @@ const unsigned int *dvb_v5_delivery_system[] = {
 	[SYS_UNDEFINED] =     NULL,
 };
 
-const void *dvbv5_attr_names[] = {
+const void *dvb_v5_attr_names[] = {
 	[0 ...DTV_MAX_COMMAND ] = NULL,
 	[DTV_CODE_RATE_HP]		= fe_code_rate_name,
 	[DTV_CODE_RATE_LP]		= fe_code_rate_name,
@@ -189,5 +187,22 @@ const void *dvbv5_attr_names[] = {
 	[DTV_DELIVERY_SYSTEM]		= delivery_system_name,
 };
 
-#endif
+const char *dvb_sat_pol_name[6] = {
+	[POLARIZATION_OFF] = "OFF",
+	[POLARIZATION_H] = "HORIZONTAL",
+	[POLARIZATION_V] = "VERTICAL",
+	[POLARIZATION_L] = "LEFT",
+	[POLARIZATION_R] = "RIGHT",
+        [5] = NULL,
+};
+
+const char *dvb_user_name[2] = {
+	[DTV_POLARIZATION - DTV_USER_COMMAND_START] =                    "POLARIZATION",
+        [1] = NULL,
+};
+
+const void *dvb_user_attr_names[] = {
+	[0 ... DTV_MAX_USER_COMMAND - DTV_USER_COMMAND_START] = NULL,
+	[DTV_POLARIZATION - DTV_USER_COMMAND_START]           = dvb_sat_pol_name,
+};
 
lib/libdvbv5/dvb-v5.c new file +230 -0

230 lines not on this page · raw message

lib/libdvbv5/dvb-v5.h +16 -229

257 lines not on this page · raw message

lib/libdvbv5/dvb-zap-format.c +1 -0
index 876395a..b087d76 100644
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "dvb-file.h"
+#include "dvb-v5-std.h"
 
 /*
  * Standard channel.conf format for DVB-T, DVB-C, DVB-S and ATSC
lib/libdvbv5/dvb_frontend.h new file +436 -0

436 lines not on this page · raw message

lib/libdvbv5/gen_dvb_structs.pl +469 -430

923 lines not on this page · raw message

lib/libdvbv5/libsat.c +5 -2
index 253e92e..e99cc25 100644
@@ -23,6 +23,7 @@
 #include <unistd.h>
 
 #include "dvb-fe.h"
+#include "dvb-v5-std.h"
 
 struct dvbsat_lnb lnb[] = {
 	{
@@ -271,7 +272,8 @@ static int dvbsat_scr_odu_channel_change(struct diseqc_cmd *cmd,
 static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 {
 	int rc;
-        enum dvbsat_polarization pol = parms->pol;
+        enum dvb_sat_polarization pol;
+        dvb_fe_retrieve_parm(parms, DTV_POLARIZATION,& pol);
 	int pol_v = (pol == POLARIZATION_V) || (pol == POLARIZATION_R);
 	int high_band = parms->high_band;
 	int sat_number = parms->sat_number;
@@ -346,7 +348,8 @@ static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 int dvb_satellite_set_parms(struct dvb_v5_fe_parms *parms)
 {
 	struct dvbsat_lnb *lnb = parms->lnb;
-        enum dvbsat_polarization pol = parms->pol;
+        enum dvb_sat_polarization pol;
+        dvb_fe_retrieve_parm(parms, DTV_POLARIZATION,& pol);
 	uint32_t freq;
 	uint16_t t = 0;
 	uint32_t voltage = SEC_VOLTAGE_13;
utils/dvb/dvbv5-scan.c +3 -2
index 125e285..256fb00 100644
@@ -35,6 +35,7 @@
 #include <linux/dvb/dmx.h>
 #include "dvb-file.h"
 #include "dvb-demux.h"
+#include "dvb-v5-std.h"
 #include "libscan.h"
 
 #define PROGRAM_NAME	"dvbv5-scan"
@@ -130,7 +131,7 @@ static int check_frontend(struct dvb_v5_fe_parms *parms, int timeout)
 static int new_freq_is_needed(struct dvb_entry *entry,
 			      struct dvb_entry *last_entry,
 			      uint32_t freq,
-			      enum dvbsat_polarization pol,
+			      enum dvb_sat_polarization pol,
 			      int shift)
 {
 	int i;
@@ -260,7 +261,7 @@ static void add_other_freq_entries(struct dvb_file *dvb_file,
 {
 	int i;
 	uint32_t freq, shift = 0;
-	enum dvbsat_polarization pol = POLARIZATION_OFF;
+	enum dvb_sat_polarization pol = POLARIZATION_OFF;
 
 	if (!dvb_desc->nit_table.frequency)
 		return;
Signature · 1 line
1.7.2.5