diff mbox

v4l-utils: Fix POLARIZATION support for dvbv5-scan

Message ID d54c86d6dcfdff0252f52e2711f8651d@tuxicoman.be (mailing list archive)
State New, archived
Headers show

Commit Message

Guy Martin May 3, 2013, 8:50 a.m. UTC
Hi all,

The attached patch fix support for the POLARIZATION parameter in 
channel files used by dvbv5-scan.
I took the liberty of removing the parsing of the 'extra DTV_foo' 
properties since they are all handled separately in dvb-file.c.
Please note that the size of struct dvb_v5_fe_parms as well as struct 
dvb_entry changes which might require a bump in library version.
Tested with DVB-S and DVB-S2.

Support for POLARIZATION is not working yet with dvbv5-zap and will 
come in a later patch.

Regards,
   Guy

dvbv5-scan: Add support for POLARIZATION setting

Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>
diff mbox

Patch

diff --git a/lib/include/dvb-fe.h b/lib/include/dvb-fe.h
index d725a42..9e87d14 100644
--- a/lib/include/dvb-fe.h
+++ b/lib/include/dvb-fe.h
@@ -104,7 +104,7 @@  struct dvb_v5_fe_parms {
 	unsigned			freq_bpf;
 
 	/* Satellite specific stuff, used internally */
-	//enum dvb_sat_polarization       pol;
+	enum dvb_sat_polarization	pol;
 	int				high_band;
 	unsigned			diseqc_wait;
 	unsigned			freq_offset;
diff --git a/lib/include/dvb-file.h b/lib/include/dvb-file.h
index ea76080..2259844 100644
--- a/lib/include/dvb-file.h
+++ b/lib/include/dvb-file.h
@@ -35,7 +35,7 @@  struct dvb_entry {
 
 	char *location;
 
-//	enum dvbsat_polarization pol;
+	enum dvb_sat_polarization pol;
 	int sat_number;
 	unsigned freq_bpf;
 	unsigned diseqc_wait;
diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c
index d8d583c..3ea40cc 100644
--- a/lib/libdvbv5/dvb-file.c
+++ b/lib/libdvbv5/dvb-file.c
@@ -392,31 +392,6 @@  static int fill_entry(struct dvb_entry *entry, char *key, char *value)
 		return 0;
 	}
 
-	/* Handle the DVB extra DTV_foo properties */
-	for (i = 0; i < ARRAY_SIZE(dvb_user_name); i++) {
-		if (!dvb_user_name[i])
-			continue;
-		if (!strcasecmp(key, dvb_user_name[i]))
-			break;
-	}
-	if (i < ARRAY_SIZE(dvb_user_name)) {
-		const char * const *attr_name = dvb_attr_names(i);
-		n_prop = entry->n_props;
-		entry->props[n_prop].cmd = i + DTV_USER_COMMAND_START;
-		if (!attr_name || !*attr_name)
-			entry->props[n_prop].u.data = atol(value);
-		else {
-			for (j = 0; attr_name[j]; j++)
-				if (!strcasecmp(value, attr_name[j]))
-					break;
-			if (!attr_name[j])
-				return -2;
-			entry->props[n_prop].u.data = j + DTV_USER_COMMAND_START;
-		}
-		entry->n_props++;
-		return 0;
-	}
-
 	/* Handle the other properties */
 
 	if (!strcasecmp(key, "SERVICE_ID")) {
@@ -453,16 +428,15 @@  static int fill_entry(struct dvb_entry *entry, char *key, char *value)
 		is_video = 1;
 	else if (!strcasecmp(key, "AUDIO_PID"))
 		is_audio = 1;
-	/*else if (!strcasecmp(key, "POLARIZATION")) {
-		entry->service_id = atol(value);
-		for (j = 0; ARRAY_SIZE(pol_name); j++)
-			if (!strcasecmp(value, pol_name[j]))
+	else if (!strcasecmp(key, "POLARIZATION")) {
+		for (j = 0; ARRAY_SIZE(dvb_sat_pol_name); j++)
+			if (!strcasecmp(value, dvb_sat_pol_name[j]))
 				break;
-		if (j == ARRAY_SIZE(pol_name))
+		if (j == ARRAY_SIZE(dvb_sat_pol_name))
 			return -2;
 		entry->pol = j;
 		return 0;
-	}*/ else if (!strncasecmp(key,"PID_", 4)){
+	} else if (!strncasecmp(key,"PID_", 4)){
 		type = strtol(&key[4], NULL, 16);
 		if (!type)
 			return 0;
@@ -672,10 +646,10 @@  int write_dvb_file(const char *fname, struct dvb_file *dvb_file)
 			fprintf(fp, "\n");
 		}
 
-		/*if (entry->pol != POLARIZATION_OFF) {*/
-			/*fprintf(fp, "\tPOLARIZATION = %s\n",*/
-				/*pol_name[entry->pol]);*/
-		/*}*/
+		if (entry->pol != POLARIZATION_OFF) {
+			fprintf(fp, "\tPOLARIZATION = %s\n",
+				dvb_sat_pol_name[entry->pol]);
+		}
 
 		if (entry->sat_number >= 0) {
 			fprintf(fp, "\tSAT_NUMBER = %d\n",
diff --git a/lib/libdvbv5/dvb-sat.c b/lib/libdvbv5/dvb-sat.c
index d00a09e..89f8e88 100644
--- a/lib/libdvbv5/dvb-sat.c
+++ b/lib/libdvbv5/dvb-sat.c
@@ -272,8 +272,7 @@  static int dvbsat_scr_odu_channel_change(struct dvb_v5_fe_parms *parms, struct d
 static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 {
 	int rc;
-	enum dvb_sat_polarization pol;
-	dvb_fe_retrieve_parm(parms, DTV_POLARIZATION,& pol);
+	enum dvb_sat_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;
@@ -284,12 +283,6 @@  static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 
 	if (!lnb->rangeswitch) {
 		/*
-		 * Bandstacking and single LO may not be using DISEqC
-		 */
-		if (sat_number < 0)
-			return 0;
-
-		/*
 		 * Bandstacking switches don't use 2 bands nor use
 		 * DISEqC for setting the polarization. It also doesn't
 		 * use any tone/tone burst
@@ -297,11 +290,6 @@  static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 		pol_v = 0;
 		high_band = 1;
 	} else {
-		if (sat_number < 0) {
-			dvb_logerr("Need a satellite number for DISEqC");
-			return -EINVAL;
-		}
-
 		/* Adjust voltage/tone accordingly */
 		if (parms->sat_number < 2) {
 			vol_high = pol_v ? 0 : 1;
@@ -310,32 +298,35 @@  static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 		}
 	}
 
-	rc = dvb_fe_sec_tone(parms, SEC_TONE_OFF);
-	if (rc)
-		return rc;
-
 	rc = dvb_fe_sec_voltage(parms, 1, vol_high);
 	if (rc)
 		return rc;
-	usleep(15 * 1000);
+	
+	if (parms->sat_number > 0) {
+		rc = dvb_fe_sec_tone(parms, SEC_TONE_OFF);
+		if (rc)
+			return rc;
 
-	if (!t)
-		rc = dvbsat_diseqc_write_to_port_group(parms, &cmd, high_band,
-						       pol_v, sat_number);
-	else
-		rc = dvbsat_scr_odu_channel_change(parms, &cmd, high_band,
-						   pol_v, sat_number, t);
+		usleep(15 * 1000);
 
-	if (rc) {
-		dvb_logerr("sending diseq failed");
-		return rc;
-	}
-	usleep((15 + parms->diseqc_wait) * 1000);
+		if (!t)
+			rc = dvbsat_diseqc_write_to_port_group(parms, &cmd, high_band,
+							       pol_v, sat_number);
+		else
+			rc = dvbsat_scr_odu_channel_change(parms, &cmd, high_band,
+							   pol_v, sat_number, t);
 
-	rc = dvb_fe_diseqc_burst(parms, mini_b);
-	if (rc)
-		return rc;
-	usleep(15 * 1000);
+		if (rc) {
+			dvb_logerr("sending diseq failed");
+			return rc;
+		}
+		usleep((15 + parms->diseqc_wait) * 1000);
+
+		rc = dvb_fe_diseqc_burst(parms, mini_b);
+		if (rc)
+			return rc;
+		usleep(15 * 1000);
+	}
 
 	rc = dvb_fe_sec_tone(parms, tone_on ? SEC_TONE_ON : SEC_TONE_OFF);
 
@@ -350,8 +341,7 @@  static int dvbsat_diseqc_set_input(struct dvb_v5_fe_parms *parms, uint16_t t)
 int dvb_sat_set_parms(struct dvb_v5_fe_parms *parms)
 {
 	const struct dvb_sat_lnb *lnb = parms->lnb;
-	enum dvb_sat_polarization pol;
-	dvb_fe_retrieve_parm(parms, DTV_POLARIZATION, &pol);
+	enum dvb_sat_polarization pol = parms->pol;
 	uint32_t freq;
 	uint16_t t = 0;
 	/*uint32_t voltage = SEC_VOLTAGE_18;*/
diff --git a/lib/libdvbv5/dvb-v5-std.c b/lib/libdvbv5/dvb-v5-std.c
index 5a1854b..53809ef 100644
--- a/lib/libdvbv5/dvb-v5-std.c
+++ b/lib/libdvbv5/dvb-v5-std.c
@@ -125,9 +125,6 @@  const unsigned int sys_dvbs_props[] = {
 	DTV_INVERSION,
 	DTV_SYMBOL_RATE,
 	DTV_INNER_FEC,
-	/*DTV_VOLTAGE,*/
-	/*DTV_TONE,*/
-	DTV_POLARIZATION,
 	0
 };
 
@@ -136,12 +133,9 @@  const unsigned int sys_dvbs2_props[] = {
 	DTV_INVERSION,
 	DTV_SYMBOL_RATE,
 	DTV_INNER_FEC,
-	/*DTV_VOLTAGE,*/
-	/*DTV_TONE,*/
 	DTV_MODULATION,
 	DTV_PILOT,
 	DTV_ROLLOFF,
-	DTV_POLARIZATION,
 	0
 };
 
@@ -150,8 +144,6 @@  const unsigned int sys_turbo_props[] = {
 	DTV_INVERSION,
 	DTV_SYMBOL_RATE,
 	DTV_INNER_FEC,
-	DTV_VOLTAGE,
-	DTV_TONE,
 	DTV_MODULATION,
 	0
 };
@@ -161,7 +153,6 @@  const unsigned int sys_isdbs_props[] = {
 	DTV_INVERSION,
 	DTV_SYMBOL_RATE,
 	DTV_INNER_FEC,
-	DTV_VOLTAGE,
 	DTV_ISDBS_TS_ID_LEGACY,
 	0
 };
diff --git a/utils/dvb/dvbv5-scan.c b/utils/dvb/dvbv5-scan.c
index 9a29b34..72cba0d 100644
--- a/utils/dvb/dvbv5-scan.c
+++ b/utils/dvb/dvbv5-scan.c
@@ -436,6 +436,9 @@  static int run_scan(struct arguments *args,
 			}
 		}
 
+		/* Copy polarity */
+		parms->pol = entry->pol;
+
 		/*
 		 * If the channel file has duplicated frequencies, or some
 		 * entries without any frequency at all, discard.