linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dvb-frontend: split set_delivery_system()
@ 2013-03-18 19:25 Mauro Carvalho Chehab
  2013-03-18 19:25 ` [PATCH 2/2] dvb_frontend: Simplify the emulation logic Mauro Carvalho Chehab
  0 siblings, 1 reply; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2013-03-18 19:25 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

This function is complex, and has different workflows, one for
DVBv3 calls, and another one for DVBv5 calls. Break it into 3
functions, in order to make easier to understand what each
block does.

No functional changes so far. A few comments got improved.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb-core/dvb_frontend.c | 292 +++++++++++++++++++---------------
 1 file changed, 164 insertions(+), 128 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 6e50a75..bbc1965 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1509,132 +1509,12 @@ static bool is_dvbv3_delsys(u32 delsys)
 	return status;
 }
 
-static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
+static int emulate_delivery_system(struct dvb_frontend *fe,
+				   enum dvbv3_emulation_type type,
+				   u32 delsys, u32 desired_system)
 {
-	int ncaps, i;
-	u32 delsys = SYS_UNDEFINED;
+	int i;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-	enum dvbv3_emulation_type type;
-
-	/*
-	 * It was reported that some old DVBv5 applications were
-	 * filling delivery_system with SYS_UNDEFINED. If this happens,
-	 * assume that the application wants to use the first supported
-	 * delivery system.
-	 */
-	if (c->delivery_system == SYS_UNDEFINED)
-	        c->delivery_system = fe->ops.delsys[0];
-
-	if (desired_system == SYS_UNDEFINED) {
-		/*
-		 * A DVBv3 call doesn't know what's the desired system.
-		 * Also, DVBv3 applications don't know that ops.info->type
-		 * could be changed, and they simply dies when it doesn't
-		 * match.
-		 * So, don't change the current delivery system, as it
-		 * may be trying to do the wrong thing, like setting an
-		 * ISDB-T frontend as DVB-T. Instead, find the closest
-		 * DVBv3 system that matches the delivery system.
-		 */
-		if (is_dvbv3_delsys(c->delivery_system)) {
-			dev_dbg(fe->dvb->device,
-					"%s: Using delivery system to %d\n",
-					__func__, c->delivery_system);
-			return 0;
-		}
-		type = dvbv3_type(c->delivery_system);
-		switch (type) {
-		case DVBV3_QPSK:
-			desired_system = SYS_DVBS;
-			break;
-		case DVBV3_QAM:
-			desired_system = SYS_DVBC_ANNEX_A;
-			break;
-		case DVBV3_ATSC:
-			desired_system = SYS_ATSC;
-			break;
-		case DVBV3_OFDM:
-			desired_system = SYS_DVBT;
-			break;
-		default:
-			dev_dbg(fe->dvb->device, "%s: This frontend doesn't support DVBv3 calls\n",
-					__func__);
-			return -EINVAL;
-		}
-		/*
-		 * Get a delivery system that is compatible with DVBv3
-		 * NOTE: in order for this to work with softwares like Kaffeine that
-		 *	uses a DVBv5 call for DVB-S2 and a DVBv3 call to go back to
-		 *	DVB-S, drivers that support both should put the SYS_DVBS entry
-		 *	before the SYS_DVBS2, otherwise it won't switch back to DVB-S.
-		 *	The real fix is that userspace applications should not use DVBv3
-		 *	and not trust on calling FE_SET_FRONTEND to switch the delivery
-		 *	system.
-		 */
-		ncaps = 0;
-		while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
-			if (fe->ops.delsys[ncaps] == desired_system) {
-				delsys = desired_system;
-				break;
-			}
-			ncaps++;
-		}
-		if (delsys == SYS_UNDEFINED) {
-			dev_dbg(fe->dvb->device, "%s: Couldn't find a delivery system that matches %d\n",
-					__func__, desired_system);
-		}
-	} else {
-		/*
-		 * This is a DVBv5 call. So, it likely knows the supported
-		 * delivery systems.
-		 */
-
-		/* Check if the desired delivery system is supported */
-		ncaps = 0;
-		while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
-			if (fe->ops.delsys[ncaps] == desired_system) {
-				c->delivery_system = desired_system;
-				dev_dbg(fe->dvb->device,
-						"%s: Changing delivery system to %d\n",
-						__func__, desired_system);
-				return 0;
-			}
-			ncaps++;
-		}
-		type = dvbv3_type(desired_system);
-
-		/*
-		 * The delivery system is not supported. See if it can be
-		 * emulated.
-		 * The emulation only works if the desired system is one of the
-		 * DVBv3 delivery systems
-		 */
-		if (!is_dvbv3_delsys(desired_system)) {
-			dev_dbg(fe->dvb->device,
-					"%s: can't use a DVBv3 FE_SET_FRONTEND call on this frontend\n",
-					__func__);
-			return -EINVAL;
-		}
-
-		/*
-		 * Get the last non-DVBv3 delivery system that has the same type
-		 * of the desired system
-		 */
-		ncaps = 0;
-		while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
-			if ((dvbv3_type(fe->ops.delsys[ncaps]) == type) &&
-			    !is_dvbv3_delsys(fe->ops.delsys[ncaps]))
-				delsys = fe->ops.delsys[ncaps];
-			ncaps++;
-		}
-		/* There's nothing compatible with the desired delivery system */
-		if (delsys == SYS_UNDEFINED) {
-			dev_dbg(fe->dvb->device,
-					"%s: Incompatible DVBv3 FE_SET_FRONTEND call for this frontend\n",
-					__func__);
-			return -EINVAL;
-		}
-	}
 
 	c->delivery_system = delsys;
 
@@ -1648,8 +1528,8 @@ static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
 	 * delivery system is the last one at the ops.delsys[] array
 	 */
 	dev_dbg(fe->dvb->device,
-			"%s: Using delivery system %d emulated as if it were a %d\n",
-			__func__, delsys, desired_system);
+		"%s: Using delivery system %d emulated as if it were a %d\n",
+		__func__, delsys, desired_system);
 
 	/*
 	 * For now, handles ISDB-T calls. More code may be needed here for the
@@ -1684,6 +1564,162 @@ static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system)
 	return 0;
 }
 
+static int dvbv5_set_delivery_system(struct dvb_frontend *fe,
+				     u32 desired_system)
+{
+	int ncaps;
+	u32 delsys = SYS_UNDEFINED;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	enum dvbv3_emulation_type type;
+
+	/*
+	 * It was reported that some old DVBv5 applications were
+	 * filling delivery_system with SYS_UNDEFINED. If this happens,
+	 * assume that the application wants to use the first supported
+	 * delivery system.
+	 */
+	if (c->delivery_system == SYS_UNDEFINED)
+	        c->delivery_system = fe->ops.delsys[0];
+
+	/*
+	* This is a DVBv5 call. So, it likely knows the supported
+	* delivery systems.
+	*/
+
+	/* Check if the desired delivery system is supported */
+	ncaps = 0;
+	while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
+		if (fe->ops.delsys[ncaps] == desired_system) {
+			c->delivery_system = desired_system;
+			dev_dbg(fe->dvb->device,
+					"%s: Changing delivery system to %d\n",
+					__func__, desired_system);
+			return 0;
+		}
+		ncaps++;
+	}
+
+	/*
+	 * Need to emulate a delivery system
+	 */
+
+	type = dvbv3_type(desired_system);
+
+	/*
+	* The delivery system is not supported. See if it can be
+	* emulated.
+	* The emulation only works if the desired system is one of the
+	* DVBv3 delivery systems
+	*/
+	if (!is_dvbv3_delsys(desired_system)) {
+		dev_dbg(fe->dvb->device,
+			"%s: can't use a DVBv3 FE_SET_FRONTEND call for this frontend\n",
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	* Get the last non-DVBv3 delivery system that has the same type
+	* of the desired system
+	*/
+	ncaps = 0;
+	while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
+		if ((dvbv3_type(fe->ops.delsys[ncaps]) == type) &&
+		    !is_dvbv3_delsys(fe->ops.delsys[ncaps]))
+			delsys = fe->ops.delsys[ncaps];
+		ncaps++;
+	}
+	/* There's nothing compatible with the desired delivery system */
+	if (delsys == SYS_UNDEFINED) {
+		dev_dbg(fe->dvb->device,
+				"%s: Incompatible DVBv3 FE_SET_FRONTEND call for this frontend\n",
+				__func__);
+		return -EINVAL;
+	}
+
+	return emulate_delivery_system(fe, type, delsys, desired_system);
+}
+
+static int dvbv3_set_delivery_system(struct dvb_frontend *fe)
+{
+	int ncaps;
+	u32 desired_system;
+	u32 delsys = SYS_UNDEFINED;
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+	enum dvbv3_emulation_type type;
+
+	/* If not set yet, defaults to the first supported delivery system */
+	if (c->delivery_system == SYS_UNDEFINED)
+	        c->delivery_system = fe->ops.delsys[0];
+
+	/*
+	 * A DVBv3 call doesn't know what's the desired system.
+	 * Also, DVBv3 applications don't know that ops.info->type
+	 * could be changed, and they simply don't tune when it doesn't
+	 * match.
+	 * So, don't change the current delivery system, as it
+	 * may be trying to do the wrong thing, like setting an
+	 * ISDB-T frontend as DVB-T. Instead, find the closest
+	 * DVBv3 system that matches the delivery system.
+	 */
+
+	/*
+	 * Trivial case: just use the current one, if it already a DVBv3
+	 * delivery system
+	 */
+	if (is_dvbv3_delsys(c->delivery_system)) {
+		dev_dbg(fe->dvb->device,
+				"%s: Using delivery system to %d\n",
+				__func__, c->delivery_system);
+		return 0;
+	}
+
+	/* Convert from DVBv3 into DVBv5 namespace */
+	type = dvbv3_type(c->delivery_system);
+	switch (type) {
+	case DVBV3_QPSK:
+		desired_system = SYS_DVBS;
+		break;
+	case DVBV3_QAM:
+		desired_system = SYS_DVBC_ANNEX_A;
+		break;
+	case DVBV3_ATSC:
+		desired_system = SYS_ATSC;
+		break;
+	case DVBV3_OFDM:
+		desired_system = SYS_DVBT;
+		break;
+	default:
+		dev_dbg(fe->dvb->device, "%s: This frontend doesn't support DVBv3 calls\n",
+				__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * Get a delivery system that is compatible with DVBv3
+	 * NOTE: in order for this to work with softwares like Kaffeine that
+	 *	uses a DVBv5 call for DVB-S2 and a DVBv3 call to go back to
+	 *	DVB-S, drivers that support both should put the SYS_DVBS entry
+	 *	before the SYS_DVBS2, otherwise it won't switch back to DVB-S.
+	 *	The real fix is that userspace applications should not use DVBv3
+	 *	and not trust on calling FE_SET_FRONTEND to switch the delivery
+	 *	system.
+	 */
+	ncaps = 0;
+	while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
+		if (fe->ops.delsys[ncaps] == desired_system) {
+			delsys = desired_system;
+			break;
+		}
+		ncaps++;
+	}
+	if (delsys == SYS_UNDEFINED) {
+		dev_dbg(fe->dvb->device, "%s: Couldn't find a delivery system that matches %d\n",
+			__func__, desired_system);
+	}
+	return emulate_delivery_system(fe, type, delsys, desired_system);
+}
+
 static int dtv_property_process_set(struct dvb_frontend *fe,
 				    struct dtv_property *tvp,
 				    struct file *file)
@@ -1742,7 +1778,7 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
 		c->rolloff = tvp->u.data;
 		break;
 	case DTV_DELIVERY_SYSTEM:
-		r = set_delivery_system(fe, tvp->u.data);
+		r = dvbv5_set_delivery_system(fe, tvp->u.data);
 		break;
 	case DTV_VOLTAGE:
 		c->voltage = tvp->u.data;
@@ -2335,7 +2371,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
 		break;
 
 	case FE_SET_FRONTEND:
-		err = set_delivery_system(fe, SYS_UNDEFINED);
+		err = dvbv3_set_delivery_system(fe);
 		if (err)
 			break;
 
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] dvb_frontend: Simplify the emulation logic
  2013-03-18 19:25 [PATCH 1/2] dvb-frontend: split set_delivery_system() Mauro Carvalho Chehab
@ 2013-03-18 19:25 ` Mauro Carvalho Chehab
  2013-03-18 20:05   ` Fabio Estevam
  0 siblings, 1 reply; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2013-03-18 19:25 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List

The current logic was broken and too complex; while it works
fine for DVB-S2/DVB-S, it is broken for ISDB-T.

Make the logic simpler, fixes it for ISDB-T and make it clearer.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb-core/dvb_frontend.c | 219 +++++++++++++++++-----------------
 1 file changed, 109 insertions(+), 110 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index bbc1965..a7317ae 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1509,9 +1509,17 @@ static bool is_dvbv3_delsys(u32 delsys)
 	return status;
 }
 
-static int emulate_delivery_system(struct dvb_frontend *fe,
-				   enum dvbv3_emulation_type type,
-				   u32 delsys, u32 desired_system)
+/**
+ * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 type
+ * @fe:			struct frontend;
+ * @desired_system:	DVBv5 type that will be used for emulation
+ *
+ * Provides emulation for delivery systems that are compatible with the old
+ * DVBv3 call. Among its usages, it provices support for ISDB-T, and allows
+ * using a DVB-S2 only frontend just like it were a DVB-S, if the frontent
+ * parameters are compatible with DVB-S spec.
+ */
+static int emulate_delivery_system(struct dvb_frontend *fe, u32 delsys)
 {
 	int i;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@@ -1519,51 +1527,52 @@ static int emulate_delivery_system(struct dvb_frontend *fe,
 	c->delivery_system = delsys;
 
 	/*
-	 * The DVBv3 or DVBv5 call is requesting a different system. So,
-	 * emulation is needed.
-	 *
-	 * Emulate newer delivery systems like ISDBT, DVBT and DTMB
-	 * for older DVBv5 applications. The emulation will try to use
-	 * the auto mode for most things, and will assume that the desired
-	 * delivery system is the last one at the ops.delsys[] array
+	 * If the call is for ISDB-T, put it into full-seg, auto mode, TV
 	 */
-	dev_dbg(fe->dvb->device,
-		"%s: Using delivery system %d emulated as if it were a %d\n",
-		__func__, delsys, desired_system);
+	if (c->delivery_system == SYS_ISDBT) {
+		dev_dbg(fe->dvb->device,
+			"%s: Using defaults for SYS_ISDBT\n",
+			__func__);
 
-	/*
-	 * For now, handles ISDB-T calls. More code may be needed here for the
-	 * other emulated stuff
-	 */
-	if (type == DVBV3_OFDM) {
-		if (c->delivery_system == SYS_ISDBT) {
-			dev_dbg(fe->dvb->device,
-					"%s: Using defaults for SYS_ISDBT\n",
-					__func__);
-
-			if (!c->bandwidth_hz)
-				c->bandwidth_hz = 6000000;
-
-			c->isdbt_partial_reception = 0;
-			c->isdbt_sb_mode = 0;
-			c->isdbt_sb_subchannel = 0;
-			c->isdbt_sb_segment_idx = 0;
-			c->isdbt_sb_segment_count = 0;
-			c->isdbt_layer_enabled = 0;
-			for (i = 0; i < 3; i++) {
-				c->layer[i].fec = FEC_AUTO;
-				c->layer[i].modulation = QAM_AUTO;
-				c->layer[i].interleaving = 0;
-				c->layer[i].segment_count = 0;
-			}
+		if (!c->bandwidth_hz)
+			c->bandwidth_hz = 6000000;
+
+		c->isdbt_partial_reception = 0;
+		c->isdbt_sb_mode = 0;
+		c->isdbt_sb_subchannel = 0;
+		c->isdbt_sb_segment_idx = 0;
+		c->isdbt_sb_segment_count = 0;
+		c->isdbt_layer_enabled = 7;
+		for (i = 0; i < 3; i++) {
+			c->layer[i].fec = FEC_AUTO;
+			c->layer[i].modulation = QAM_AUTO;
+			c->layer[i].interleaving = 0;
+			c->layer[i].segment_count = 0;
 		}
 	}
 	dev_dbg(fe->dvb->device, "%s: change delivery system on cache to %d\n",
-			__func__, c->delivery_system);
+		__func__, c->delivery_system);
 
 	return 0;
 }
 
+/**
+ * dvbv5_set_delivery_system - Sets the delivery system for a DVBv5 API call
+ * @fe:			frontend struct
+ * @desired_system:	delivery system requested by the user
+ *
+ * A DVBv5 call know what's the desired system it wants. So, set it.
+ *
+ * There are, however, a few known issues with early DVBv5 applications that
+ * are also handled by this logic:
+ *
+ * 1) Some early apps use SYS_UNDEFINED as the desired delivery system.
+ *    This is an API violation, but, as we don't want to break userspace,
+ *    convert it to the first supported delivery system.
+ * 2) Some apps might be using a DVBv5 call in a wrong way, passing, for
+ *    example, SYS_DVBT instead of SYS_ISDBT. This is because early usage of
+ *    ISDB-T provided backward compat with DVB-T.
+ */
 static int dvbv5_set_delivery_system(struct dvb_frontend *fe,
 				     u32 desired_system)
 {
@@ -1578,15 +1587,14 @@ static int dvbv5_set_delivery_system(struct dvb_frontend *fe,
 	 * assume that the application wants to use the first supported
 	 * delivery system.
 	 */
-	if (c->delivery_system == SYS_UNDEFINED)
-	        c->delivery_system = fe->ops.delsys[0];
+	if (desired_system == SYS_UNDEFINED)
+	        desired_system = fe->ops.delsys[0];
 
 	/*
-	* This is a DVBv5 call. So, it likely knows the supported
-	* delivery systems.
-	*/
-
-	/* Check if the desired delivery system is supported */
+	 * This is a DVBv5 call. So, it likely knows the supported
+	 * delivery systems. So, check if the desired delivery system is
+	 * supported
+	 */
 	ncaps = 0;
 	while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
 		if (fe->ops.delsys[ncaps] == desired_system) {
@@ -1600,70 +1608,86 @@ static int dvbv5_set_delivery_system(struct dvb_frontend *fe,
 	}
 
 	/*
-	 * Need to emulate a delivery system
+	 * The requested delivery system isn't supported. Maybe userspace
+	 * is requesting a DVBv3 compatible delivery system.
+	 *
+	 * The emulation only works if the desired system is one of the
+	 * delivery systems supported by DVBv3 API
 	 */
-
-	type = dvbv3_type(desired_system);
-
-	/*
-	* The delivery system is not supported. See if it can be
-	* emulated.
-	* The emulation only works if the desired system is one of the
-	* DVBv3 delivery systems
-	*/
 	if (!is_dvbv3_delsys(desired_system)) {
 		dev_dbg(fe->dvb->device,
-			"%s: can't use a DVBv3 FE_SET_FRONTEND call for this frontend\n",
-			__func__);
+			"%s: Delivery system %d not supported.\n",
+			__func__, desired_system);
 		return -EINVAL;
 	}
 
+	type = dvbv3_type(desired_system);
+
 	/*
 	* Get the last non-DVBv3 delivery system that has the same type
 	* of the desired system
 	*/
 	ncaps = 0;
 	while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
-		if ((dvbv3_type(fe->ops.delsys[ncaps]) == type) &&
-		    !is_dvbv3_delsys(fe->ops.delsys[ncaps]))
+		if (dvbv3_type(fe->ops.delsys[ncaps]) == type)
 			delsys = fe->ops.delsys[ncaps];
 		ncaps++;
 	}
+
 	/* There's nothing compatible with the desired delivery system */
 	if (delsys == SYS_UNDEFINED) {
 		dev_dbg(fe->dvb->device,
-				"%s: Incompatible DVBv3 FE_SET_FRONTEND call for this frontend\n",
-				__func__);
+			"%s: Delivery system %d not supported on emulation mode.\n",
+			__func__, desired_system);
 		return -EINVAL;
 	}
 
-	return emulate_delivery_system(fe, type, delsys, desired_system);
+	dev_dbg(fe->dvb->device,
+		"%s: Using delivery system %d emulated as if it were %d\n",
+		__func__, delsys, desired_system);
+
+	return emulate_delivery_system(fe, desired_system);
 }
 
+/**
+ * dvbv3_set_delivery_system - Sets the delivery system for a DVBv3 API call
+ * @fe:	frontend struct
+ *
+ * A DVBv3 call doesn't know what's the desired system it wants. It also
+ * doesn't allow to switch between different types. Due to that, userspace
+ * should use DVBv5 instead.
+ * However, in order to avoid breaking userspace API, limited backward
+ * compatibility support is provided.
+ *
+ * There are some delivery systems that are incompatible with DVBv3 calls.
+ *
+ * This routine should work fine for frontends that support just one delivery
+ * system.
+ *
+ * For frontends that support multiple frontends:
+ * 1) It defaults to use the first supported delivery system. There's an
+ *    userspace application that allows changing it at runtime;
+ *
+ * 2) If the current delivery system is not compatible with DVBv3, it gets
+ *    the first one that it is compatible.
+ *
+ * NOTE: in order for this to work with applications like Kaffeine that
+ *	uses a DVBv5 call for DVB-S2 and a DVBv3 call to go back to
+ *	DVB-S, drivers that support both DVB-S and DVB-S2 should have the
+ * 	SYS_DVBS entry before the SYS_DVBS2, otherwise it won't switch back
+ *	to DVB-S.
+ */
 static int dvbv3_set_delivery_system(struct dvb_frontend *fe)
 {
 	int ncaps;
-	u32 desired_system;
 	u32 delsys = SYS_UNDEFINED;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-	enum dvbv3_emulation_type type;
 
 	/* If not set yet, defaults to the first supported delivery system */
 	if (c->delivery_system == SYS_UNDEFINED)
 	        c->delivery_system = fe->ops.delsys[0];
 
 	/*
-	 * A DVBv3 call doesn't know what's the desired system.
-	 * Also, DVBv3 applications don't know that ops.info->type
-	 * could be changed, and they simply don't tune when it doesn't
-	 * match.
-	 * So, don't change the current delivery system, as it
-	 * may be trying to do the wrong thing, like setting an
-	 * ISDB-T frontend as DVB-T. Instead, find the closest
-	 * DVBv3 system that matches the delivery system.
-	 */
-
-	/*
 	 * Trivial case: just use the current one, if it already a DVBv3
 	 * delivery system
 	 */
@@ -1674,50 +1698,25 @@ static int dvbv3_set_delivery_system(struct dvb_frontend *fe)
 		return 0;
 	}
 
-	/* Convert from DVBv3 into DVBv5 namespace */
-	type = dvbv3_type(c->delivery_system);
-	switch (type) {
-	case DVBV3_QPSK:
-		desired_system = SYS_DVBS;
-		break;
-	case DVBV3_QAM:
-		desired_system = SYS_DVBC_ANNEX_A;
-		break;
-	case DVBV3_ATSC:
-		desired_system = SYS_ATSC;
-		break;
-	case DVBV3_OFDM:
-		desired_system = SYS_DVBT;
-		break;
-	default:
-		dev_dbg(fe->dvb->device, "%s: This frontend doesn't support DVBv3 calls\n",
-				__func__);
-		return -EINVAL;
-	}
-
 	/*
-	 * Get a delivery system that is compatible with DVBv3
-	 * NOTE: in order for this to work with softwares like Kaffeine that
-	 *	uses a DVBv5 call for DVB-S2 and a DVBv3 call to go back to
-	 *	DVB-S, drivers that support both should put the SYS_DVBS entry
-	 *	before the SYS_DVBS2, otherwise it won't switch back to DVB-S.
-	 *	The real fix is that userspace applications should not use DVBv3
-	 *	and not trust on calling FE_SET_FRONTEND to switch the delivery
-	 *	system.
+	 * Seek for the first delivery system that it is compatible with a
+	 * DVBv3 standard
 	 */
 	ncaps = 0;
 	while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) {
-		if (fe->ops.delsys[ncaps] == desired_system) {
-			delsys = desired_system;
+		if (dvbv3_type(fe->ops.delsys[ncaps]) != DVBV3_UNKNOWN) {
+			delsys = fe->ops.delsys[ncaps];
 			break;
 		}
 		ncaps++;
 	}
 	if (delsys == SYS_UNDEFINED) {
-		dev_dbg(fe->dvb->device, "%s: Couldn't find a delivery system that matches %d\n",
-			__func__, desired_system);
+		dev_dbg(fe->dvb->device,
+			"%s: Couldn't find a delivery system that works with FE_SET_FRONTEND\n",
+			__func__);
+		return -EINVAL;
 	}
-	return emulate_delivery_system(fe, type, delsys, desired_system);
+	return emulate_delivery_system(fe, delsys);
 }
 
 static int dtv_property_process_set(struct dvb_frontend *fe,
-- 
1.8.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] dvb_frontend: Simplify the emulation logic
  2013-03-18 19:25 ` [PATCH 2/2] dvb_frontend: Simplify the emulation logic Mauro Carvalho Chehab
@ 2013-03-18 20:05   ` Fabio Estevam
  2013-03-18 23:35     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2013-03-18 20:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List

Hi Mauro,

On Mon, Mar 18, 2013 at 4:25 PM, Mauro Carvalho Chehab
<mchehab@redhat.com> wrote:

> -static int emulate_delivery_system(struct dvb_frontend *fe,
> -                                  enum dvbv3_emulation_type type,
> -                                  u32 delsys, u32 desired_system)
> +/**
> + * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 type
> + * @fe:                        struct frontend;
> + * @desired_system:    DVBv5 type that will be used for emulation

'desired_system' parameter has been removed in this patch. 'delsys'
should be put in the description instead.

> + * Provides emulation for delivery systems that are compatible with the old
> + * DVBv3 call. Among its usages, it provices support for ISDB-T, and allows
> + * using a DVB-S2 only frontend just like it were a DVB-S, if the frontent
> + * parameters are compatible with DVB-S spec.
> + */
> +static int emulate_delivery_system(struct dvb_frontend *fe, u32 delsys)

Regards,

Fabio Estevam

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] dvb_frontend: Simplify the emulation logic
  2013-03-18 20:05   ` Fabio Estevam
@ 2013-03-18 23:35     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2013-03-18 23:35 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Linux Media Mailing List

Em Mon, 18 Mar 2013 17:05:12 -0300
Fabio Estevam <festevam@gmail.com> escreveu:

> Hi Mauro,
> 
> On Mon, Mar 18, 2013 at 4:25 PM, Mauro Carvalho Chehab
> <mchehab@redhat.com> wrote:
> 
> > -static int emulate_delivery_system(struct dvb_frontend *fe,
> > -                                  enum dvbv3_emulation_type type,
> > -                                  u32 delsys, u32 desired_system)
> > +/**
> > + * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 type
> > + * @fe:                        struct frontend;
> > + * @desired_system:    DVBv5 type that will be used for emulation
> 
> 'desired_system' parameter has been removed in this patch. 'delsys'
> should be put in the description instead.

Thanks for reviewing it!

Yeah, internally I made several versions of this patch, in order to make
each routine clear. On the very last minute, I ended by just removing
desired_system, keeping just one parameter there after fe.

I'm changing it at the version I'm committing.

Thanks!
Mauro

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-18 23:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18 19:25 [PATCH 1/2] dvb-frontend: split set_delivery_system() Mauro Carvalho Chehab
2013-03-18 19:25 ` [PATCH 2/2] dvb_frontend: Simplify the emulation logic Mauro Carvalho Chehab
2013-03-18 20:05   ` Fabio Estevam
2013-03-18 23:35     ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).