MythTV and multiproto API works!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To all,

We can already use VDR on our multiproto cards (thanks to Reinhard and
others).

But, for everyone who likes to use MythTV I have good news! 

With the following patch you can watch TV using the multiproto API. I am
currently zapping around with my TT3200 and it works great. :)

I must admin that this patch is not what I call a real patch, it is more
a quick hack and it currently only supports DVB-S. I intend to support
DVB-S2 soon with a clean (configurable) approach within MythTV. Further,
the Channel Scanner (in mythtv-setup) once in the 3 times crashes on me
so you have to be persistent if you want to automatically scan the
channels. I am unsure if this is driver or a Myth problem.

For everybody who cannot wait, please use the supplied patch on one of
the latest SVN builds (revision 15220). I am very interested to have
your feedback/results.

Best regards,

Mario Smit
Index: libs/libmythtv/dvbtypes.h
===================================================================
--- libs/libmythtv/dvbtypes.h	(revision 15220)
+++ libs/libmythtv/dvbtypes.h	(working copy)
@@ -39,11 +39,12 @@
 #    define VSB_16        (fe_modulation)(QAM_AUTO+2)
 #endif
 
-#ifdef FE_GET_EXTENDED_INFO
-  #define dvb_fe_params dvb_frontend_parameters_new
-#else
-  #define dvb_fe_params dvb_frontend_parameters
-#endif
+// TODO: remove clash with dvb_frontend_parameters_new (older implementation effort multiproto)
+//#ifdef FE_GET_EXTENDED_INFO
+//  #define dvb_fe_params dvb_frontend_parameters_new
+//#else
+//  #define dvb_fe_params dvb_frontend_parameters
+//#endif
 
 class QString;
 QString toString(fe_status);
Index: libs/libmythtv/dvbchannel.cpp
===================================================================
--- libs/libmythtv/dvbchannel.cpp	(revision 15220)
+++ libs/libmythtv/dvbchannel.cpp	(working copy)
@@ -50,10 +50,10 @@
 
 static void drain_dvb_events(int fd);
 static bool wait_for_backend(int fd, int timeout_ms);
-static struct dvb_fe_params dtvmultiplex_to_dvbparams(
+static struct dvb_frontend_parameters dtvmultiplex_to_dvbparams(
     DTVTunerType, const DTVMultiplex&);
 static DTVMultiplex dvbparams_to_dtvmultiplex(
-    DTVTunerType, const dvb_fe_params&);
+    DTVTunerType, const dvb_frontend_parameters&);
 
 #define LOC QString("DVBChan(%1): ").arg(cardnum)
 #define LOC_WARN QString("DVBChan(%1) Warning: ").arg(cardnum)
@@ -137,7 +137,19 @@
         fd_frontend = -1;
         return false;
     }
+    VERBOSE(VB_IMPORTANT, LOC + "Getting additional DVBFE_GET_INFO information." + ENO);
+    dvbfe_info fe_info;
+    bzero(&fe_info, sizeof(fe_info));
+    fe_info.delivery = DVBFE_DELSYS_DVBS;
+    if (ioctl(fd_frontend, DVBFE_GET_INFO, &fe_info) < 0)
+    {
+        VERBOSE(VB_IMPORTANT, LOC_ERR +
+                "Failed to get additional DVBFE_GET_INFO information." + ENO);
 
+        close(fd_frontend);
+        fd_frontend = -1;
+        return false;
+    }
 #ifdef FE_GET_EXTENDED_INFO
     if (info.caps & FE_HAS_EXTENDED_INFO)
     {
@@ -560,7 +572,7 @@
     QMutexLocker lock(&tune_lock);
 
     bool reset = (force_reset || first_tune);
-    struct dvb_fe_params params = dtvmultiplex_to_dvbparams(card_type, tuning);
+    struct dvb_frontend_parameters params = dtvmultiplex_to_dvbparams(card_type, tuning);
 
     bool is_dvbs = (DTVTunerType::kTunerTypeQPSK   == card_type ||
                     DTVTunerType::kTunerTypeDVB_S2 == card_type);
@@ -646,27 +658,71 @@
         VERBOSE(VB_CHANNEL, LOC + QString("Tune(): Tuning to %1%2")
                 .arg(params.frequency).arg(suffix));
 
-#ifdef FE_GET_EXTENDED_INFO
-        if (card_type == DTVTunerType::kTunerTypeDVB_S2)
-        {
-            if (ioctl(fd_frontend, FE_SET_FRONTEND2, &params) < 0)
-            {
-                VERBOSE(VB_IMPORTANT, LOC_ERR + "Tune(): " +
-                        "Setting Frontend(2) tuning parameters failed." + ENO);
-                return false;
-            }
-        }
-        else
-#endif // FE_GET_EXTENDED_INFO
-        {
-            if (ioctl(fd_frontend, FE_SET_FRONTEND, &params) < 0)
-            {
-                VERBOSE(VB_IMPORTANT, LOC_ERR + "Tune(): " +
-                        "Setting Frontend tuning parameters failed." + ENO);
-                return false;
-            }
-        }
+	// check for multiproto API
+	if ((DVB_API_VERSION == 3) && (DVB_API_VERSION_MINOR == 3)) {
+		struct dvbfe_params fe_params;
+		unsigned int delsys = DVBFE_DELSYS_DVBS; //TODO: should come from configuration/database
 
+		VERBOSE(VB_CHANNEL, LOC + "Tune(): " +
+                        QString("API minor version=%1, delivery system = %2").arg(DVB_API_VERSION_MINOR).arg(delsys));
+
+		fe_params.frequency = params.frequency;
+		fe_params.inversion = INVERSION_AUTO;
+		
+		switch (delsys) 
+		{
+		case DVBFE_DELSYS_DVBS:
+			fe_params.delsys.dvbs.symbol_rate = params.u.qpsk.symbol_rate;
+			fe_params.delsys.dvbs.fec = DVBFE_FEC_AUTO;
+			fe_params.delsys.dvbs.modulation = DVBFE_MOD_AUTO;
+            		fe_params.delivery= DVBFE_DELSYS_DVBS;
+			VERBOSE(VB_CHANNEL, LOC + "Tune(): " +
+                        	QString("Frequency = %2, Srate = %3 (DVB-S)").arg(fe_params.frequency).arg(fe_params.delsys.dvbs.symbol_rate));
+			break;
+		case DVBFE_DELSYS_DVBS2:
+			fe_params.delsys.dvbs2.symbol_rate = params.u.qpsk.symbol_rate; //TODO: should use the new symbol_rate type
+			fe_params.delsys.dvbs2.fec = DVBFE_FEC_AUTO; //TODO: should use the new FEC options
+			fe_params.delsys.dvbs.modulation = DVBFE_MOD_AUTO;
+            		fe_params.delivery= DVBFE_DELSYS_DVBS2;
+			VERBOSE(VB_CHANNEL, LOC + "Tune(): " +
+                        	QString("Frequency = %2, Srate = %3 (DVB-S2)").arg(fe_params.frequency).arg(fe_params.delsys.dvbs2.symbol_rate));
+			break;
+		default:
+			return false;
+		}
+		VERBOSE(VB_CHANNEL, LOC + "Tune(): " +
+                        QString("Frequency = %1, Srate = %2 (SET_PARAMS)").arg(fe_params.frequency).arg(fe_params.delsys.dvbs.symbol_rate));
+
+		if (ioctl(fd_frontend, DVBFE_SET_PARAMS, &fe_params) == -1) {
+			VERBOSE(VB_IMPORTANT, LOC_ERR + "Tune(): " +
+                        	"DVBFE_SET_PARAMS failed");
+			return false;
+		}
+
+	}
+	else // old code.... TODO: need to find a more elegant way to distinguish between API/protocol versions
+	{
+	#ifdef FE_GET_EXTENDED_INFO
+		if (card_type == DTVTunerType::kTunerTypeDVB_S2)
+		{
+		if (ioctl(fd_frontend, FE_SET_FRONTEND2, &params) < 0)
+		{
+			VERBOSE(VB_IMPORTANT, LOC_ERR + "Tune(): " +
+				"Setting Frontend(2) tuning parameters failed." + ENO);
+			return false;
+		}
+		}
+		else
+	#endif // FE_GET_EXTENDED_INFO
+		{
+		if (ioctl(fd_frontend, FE_SET_FRONTEND, &params) < 0)
+		{
+			VERBOSE(VB_IMPORTANT, LOC_ERR + "Tune(): " +
+				"Setting Frontend tuning parameters failed." + ENO);
+			return false;
+		}
+		}
+	}
         // Extra delay to add for broken DVB drivers
         if (tuning_delay)
             usleep(tuning_delay * 1000);
@@ -714,7 +770,7 @@
         return false;
     }
 
-    dvb_fe_params params;
+    dvb_frontend_parameters params;
     return ioctl(fd_frontend, FE_GET_FRONTEND, &params) >= 0;
 }
 
@@ -742,7 +798,7 @@
         return false;
     }
 
-    dvb_fe_params params;
+    dvb_frontend_parameters params;
     if (ioctl(fd_frontend, FE_GET_FRONTEND, &params) < 0)
     {
         VERBOSE(VB_IMPORTANT, LOC_ERR +
@@ -875,10 +931,10 @@
     return true;
 }
 
-static struct dvb_fe_params dtvmultiplex_to_dvbparams(
+static struct dvb_frontend_parameters dtvmultiplex_to_dvbparams(
     DTVTunerType tuner_type, const DTVMultiplex &tuning)
 {
-    dvb_fe_params params;
+    dvb_frontend_parameters params;
     bzero(&params, sizeof(params));
 
     params.frequency = tuning.frequency;
@@ -939,7 +995,7 @@
 }
 
 static DTVMultiplex dvbparams_to_dtvmultiplex(
-    DTVTunerType tuner_type, const dvb_fe_params &params)
+    DTVTunerType tuner_type, const dvb_frontend_parameters &params)
 {
     DTVMultiplex tuning;
 
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux