[mythtv] [patch] firewire broadcast connection

Jim Westfall jwestfall at surrealistic.net
Sun Mar 6 04:32:45 UTC 2005


re-submitting.  updated for current cvs and adds in the libeic61883 api 
change.

jim

Jim Westfall <jwestfall at surrealistic.net> wrote [02.15.05]:
> Hi
> 
> With the help of ddennedy over at linux1394 it was determined that not all 
> STB's are stable or dont even work when making a peer to peer connection. 
> 
> This patch adds a new option that lets you pick the connection type to 
> make with the STB, p2p or broadcast.  Its been tested with a couple 
> problematic DCT-6200 boxes. 
> 
> jim

> diff -ur mythtv.orig/libs/libmythtv/dbcheck.cpp mythtv/libs/libmythtv/dbcheck.cpp
> --- mythtv.orig/libs/libmythtv/dbcheck.cpp	2005-02-12 10:33:43.000000000 -0800
> +++ mythtv/libs/libmythtv/dbcheck.cpp	2005-02-12 10:36:54.000000000 -0800
> @@ -9,7 +9,7 @@
>  #include "mythcontext.h"
>  #include "mythdbcon.h"
>  
> -const QString currentDatabaseVersion = "1071";
> +const QString currentDatabaseVersion = "1072";
>  
>  static bool UpdateDBVersionNumber(const QString &newnumber);
>  static bool performActualUpdate(const QString updates[], QString version,
> @@ -1399,6 +1399,16 @@
>              return false;
>      }
>  
> +    if (dbver == "1071")
> +    {
> +        const QString updates[] = {
> +"ALTER TABLE capturecard ADD COLUMN firewire_connection INT UNSIGNED NOT NULL DEFAULT 0;",
> +""
> +};
> +        if (!performActualUpdate(updates, "1072", dbver))
> +            return false;
> +    }
> +
>      return true;
>  }
>  
> diff -ur mythtv.orig/libs/libmythtv/firewirerecorder.cpp mythtv/libs/libmythtv/firewirerecorder.cpp
> --- mythtv.orig/libs/libmythtv/firewirerecorder.cpp	2005-02-12 10:33:43.000000000 -0800
> +++ mythtv/libs/libmythtv/firewirerecorder.cpp	2005-02-12 11:47:31.515478918 -0800
> @@ -21,7 +21,7 @@
>       if(!fw) return 0;
>  
>       if(dropped) {
> -         VERBOSE(VB_GENERAL,QString("FireWire: %1 packet(s) dropped.").arg(dropped));
> +         VERBOSE(VB_GENERAL,QString("Firewire: %1 packet(s) dropped.").arg(dropped));
>       }
>       fw->ProcessTSPacket(tspacket,len);
>       return 1;
> @@ -39,20 +39,20 @@
>      fwhandle = NULL;
>      fwmpeg = NULL;
>      fwfd = -1;
> -           
> +    fwconnection = FIREWIRE_CONNECTION_P2P;
>  }
>  
>  FirewireRecorder::~FirewireRecorder() {
>  
>      if(isopen) {
> -        VERBOSE(VB_GENERAL,QString("FireWire: releasing iec61883_mpeg2 object"));
> +        VERBOSE(VB_GENERAL,QString("Firewire: releasing iec61883_mpeg2 object"));
>          iec61883_mpeg2_close(fwmpeg);
> -        if(fwchannel > -1) {
> -              VERBOSE(VB_GENERAL,QString("FireWire: disconnecting channel %1").arg(fwchannel));
> +        if(fwconnection == FIREWIRE_CONNECTION_P2P && fwchannel > -1) {
> +              VERBOSE(VB_GENERAL,QString("Firewire: disconnecting channel %1").arg(fwchannel));
>  	      iec61883_cmp_disconnect (fwhandle, fwnode | 0xffc0,
>                     raw1394_get_local_id (fwhandle), fwchannel, fwbandwidth);
>          }
> -        VERBOSE(VB_GENERAL,QString("FireWire: releasing raw1394 handle"));
> +        VERBOSE(VB_GENERAL,QString("Firewire: releasing raw1394 handle"));
>          raw1394_destroy_handle(fwhandle);
>      }    
>      isopen = false;
> @@ -63,7 +63,7 @@
>       if(isopen)
>           return true;
>      
> -     VERBOSE(VB_GENERAL,QString("FireWire: Initializing Port: %1, Node: %2, Speed: %3")
> +     VERBOSE(VB_GENERAL,QString("Firewire: Initializing Port: %1, Node: %2, Speed: %3")
>                                 .arg(fwport)
>                                 .arg(fwnode)
>                                 .arg(FirewireSpeedString(fwspeed)));
> @@ -74,13 +74,26 @@
>           return false;
>       }
>  
> -     fwchannel = iec61883_cmp_connect (fwhandle, fwnode | 0xffc0,
> +     if(fwconnection == FIREWIRE_CONNECTION_P2P) {
> +          VERBOSE(VB_GENERAL,QString("Firewire: Creating P2P Connection with Node: %1").arg(fwnode));
> +          fwchannel = iec61883_cmp_connect (fwhandle, fwnode | 0xffc0,
>                          raw1394_get_local_id (fwhandle), &fwbandwidth);
> -
> -     if(fwchannel > -1) {
> -	VERBOSE(VB_GENERAL,QString("FireWire: Created Channel: %1, Bandwidth Allocation: %2").arg(fwchannel).arg(fwbandwidth));
> +          if(fwchannel > -1) {
> +	      VERBOSE(VB_GENERAL,QString("Firewire: Created Channel: %1, Bandwidth Allocation: %2").arg(fwchannel).arg(fwbandwidth));
> +          }
> +     } else {
> +          VERBOSE(VB_GENERAL,QString("Firewire: Creating Broadcast Connection with Node: %1").arg(fwnode));
> +          if(iec61883_cmp_create_bcast_output(fwhandle, fwnode | 0xffc0, 0, FIREWIRE_CHANNEL_BROADCAST, fwspeed) != 0) {
> +	      VERBOSE(VB_IMPORTANT, QString("Firewire: Failed to create connection"));
> +	      // release raw1394 object;
> +              raw1394_destroy_handle(fwhandle);
> +              return false;
> +          }
> +          fwchannel = FIREWIRE_CHANNEL_BROADCAST;
> +          fwbandwidth = 0;
>       }
>  
> +
>       if((fwmpeg = iec61883_mpeg2_recv_init (fwhandle, read_tspacket, this)) == NULL) {
>           VERBOSE(VB_IMPORTANT, QString("Firewire: unable to init iec61883_mpeg2 object, bailing"));
>           perror("iec61883_mpeg2 object");
> @@ -94,7 +107,7 @@
>       // probably shouldnt even allow user to set, 100Mbps should be more the enough
>       int curspeed = iec61883_mpeg2_get_speed(fwmpeg);
>       if(curspeed != fwspeed) {
> -         VERBOSE(VB_GENERAL,QString("FireWire: Changing Speed %1 -> %2")
> +         VERBOSE(VB_GENERAL,QString("Firewire: Changing Speed %1 -> %2")
>                                      .arg(FirewireSpeedString(curspeed))
>                                      .arg(FirewireSpeedString(fwspeed)));
>           iec61883_mpeg2_set_speed(fwmpeg, fwspeed);
> @@ -214,6 +227,12 @@
>              VERBOSE(VB_IMPORTANT, QString("Firewire: Invalid speed '%1', assuming 0 (100Mbps)").arg(fwspeed));
>              fwspeed = 0;
>          }
> +    } else if(name == "connection") {
> +	fwconnection = value;
> +	if(fwconnection != FIREWIRE_CONNECTION_P2P && fwconnection != FIREWIRE_CONNECTION_BROADCAST) {
> +	    VERBOSE(VB_IMPORTANT, QString("Firewire: Invalid Connection type '%1', assuming P2P").arg(fwconnection));
> +            fwconnection = FIREWIRE_CONNECTION_P2P;
> +        }
>      }
>  }
>  
> diff -ur mythtv.orig/libs/libmythtv/firewirerecorder.h mythtv/libs/libmythtv/firewirerecorder.h
> --- mythtv.orig/libs/libmythtv/firewirerecorder.h	2005-02-01 23:11:10.000000000 -0800
> +++ mythtv/libs/libmythtv/firewirerecorder.h	2005-02-12 10:36:54.000000000 -0800
> @@ -16,6 +16,11 @@
>  
>  #define FIREWIRE_TIMEOUT 15
>  
> +#define FIREWIRE_CONNECTION_P2P		0
> +#define FIREWIRE_CONNECTION_BROADCAST	1
> +
> +#define FIREWIRE_CHANNEL_BROADCAST	63
> +
>  class FirewireRecorder : public DTVRecorder
>  {
>    public:
> @@ -36,7 +41,7 @@
>      QString FirewireSpeedString(int speed);
>  
>    private:
> -    int fwport, fwchannel, fwspeed, fwbandwidth, fwfd;
> +    int fwport, fwchannel, fwspeed, fwbandwidth, fwfd, fwconnection;
>      QString fwmodel;
>      nodeid_t fwnode;
>      raw1394handle_t fwhandle;
> diff -ur mythtv.orig/libs/libmythtv/tv_rec.cpp mythtv/libs/libmythtv/tv_rec.cpp
> --- mythtv.orig/libs/libmythtv/tv_rec.cpp	2005-02-02 09:17:24.000000000 -0800
> +++ mythtv/libs/libmythtv/tv_rec.cpp	2005-02-12 10:36:54.000000000 -0800
> @@ -678,6 +678,7 @@
>          nvr->SetOption("node", firewire_options.node);
>          nvr->SetOption("speed", firewire_options.speed);
>          nvr->SetOption("model", firewire_options.model);
> +        nvr->SetOption("connection", firewire_options.connection);
>          nvr->Initialize();
>  #endif
>          return;
> @@ -1153,7 +1154,7 @@
>                                 "dvb_wait_for_seqstart,dvb_dmx_buf_size,"
>                                 "dvb_pkt_buf_size, skipbtaudio, dvb_on_demand,"
>                                 "firewire_port, firewire_node, firewire_speed,"
> -                               "firewire_model "
> +                               "firewire_model, firewire_connection "
>                                 "FROM capturecard WHERE cardid = %1;")
>                                .arg(cardnum);
>  
> @@ -1204,6 +1205,7 @@
>          test = query.value(16).toString();
>          if (test != QString::null)
>  	   firewire_opts.model = QString::fromUtf8(test);
> +        firewire_opts.connection = query.value(17).toInt();
>      }
>  
>      thequery = QString("SELECT if(startchan!='', startchan, '3') "
> diff -ur mythtv.orig/libs/libmythtv/tv_rec.h mythtv/libs/libmythtv/tv_rec.h
> --- mythtv.orig/libs/libmythtv/tv_rec.h	2005-02-01 23:11:10.000000000 -0800
> +++ mythtv/libs/libmythtv/tv_rec.h	2005-02-12 10:36:54.000000000 -0800
> @@ -46,6 +46,7 @@
>      int port;
>      int node;
>      int speed;
> +    int connection;
>      QString model;
>  } firewire_options_t;
>  
> diff -ur mythtv.orig/libs/libmythtv/videosource.cpp mythtv/libs/libmythtv/videosource.cpp
> --- mythtv.orig/libs/libmythtv/videosource.cpp	2005-02-12 10:33:44.000000000 -0800
> +++ mythtv/libs/libmythtv/videosource.cpp	2005-02-12 10:36:54.000000000 -0800
> @@ -857,6 +857,16 @@
>          }
>  };
>  
> +class FirewireConnection: public ComboBoxSetting, public CCSetting {
> +    public:
> +	FirewireConnection(const CaptureCard& parent):
> + 	CCSetting(parent, "firewire_connection") {
> +            setLabel(QObject::tr("Firewire Connection Type"));
> +            addSelection(QObject::tr("Point to Point"),"0");
> +            addSelection(QObject::tr("Broadcast"),"1");
> +        }
> +};
> +
>  class FirewirePort: public LineEditSetting, public CCSetting {
>      public:
>  	FirewirePort(const CaptureCard& parent):
> @@ -904,6 +914,7 @@
>          parent(a_parent) {
>          setUseLabel(false);
>          addChild(new FirewireModel(parent));
> +        addChild(new FirewireConnection(parent));
>          addChild(new FirewirePort(parent));
>          addChild(new FirewireNode(parent));
>          addChild(new FirewireSpeed(parent));

> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

-------------- next part --------------
Index: libs/libmythtv/dbcheck.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/dbcheck.cpp,v
retrieving revision 1.88
diff -u -r1.88 dbcheck.cpp
--- libs/libmythtv/dbcheck.cpp	25 Feb 2005 01:24:12 -0000	1.88
+++ libs/libmythtv/dbcheck.cpp	6 Mar 2005 02:50:50 -0000
@@ -9,7 +9,7 @@
 #include "mythcontext.h"
 #include "mythdbcon.h"
 
-const QString currentDatabaseVersion = "1073";
+const QString currentDatabaseVersion = "1074";
 
 static bool UpdateDBVersionNumber(const QString &newnumber);
 static bool performActualUpdate(const QString updates[], QString version,
@@ -1427,6 +1427,19 @@
             return false;
     }
 
+    if (dbver == "1073")
+    {
+        const QString updates[] = {
+"ALTER TABLE capturecard ADD COLUMN firewire_connection INT UNSIGNED NOT NULL DEFAULT 0;",
+""
+};
+        if (!performActualUpdate(updates, "1074", dbver))
+            return false;
+    }
+
+
+
+
     return true;
 }
 
Index: libs/libmythtv/firewirerecorder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/firewirerecorder.cpp,v
retrieving revision 1.2
diff -u -r1.2 firewirerecorder.cpp
--- libs/libmythtv/firewirerecorder.cpp	8 Feb 2005 07:35:43 -0000	1.2
+++ libs/libmythtv/firewirerecorder.cpp	6 Mar 2005 02:50:50 -0000
@@ -21,7 +21,7 @@
      if(!fw) return 0;
 
      if(dropped) {
-         VERBOSE(VB_GENERAL,QString("FireWire: %1 packet(s) dropped.").arg(dropped));
+         VERBOSE(VB_GENERAL,QString("Firewire: %1 packet(s) dropped.").arg(dropped));
      }
      fw->ProcessTSPacket(tspacket,len);
      return 1;
@@ -39,20 +39,22 @@
     fwhandle = NULL;
     fwmpeg = NULL;
     fwfd = -1;
-           
+    fwoplug = -1;
+    fwiplug = -1;
+    fwconnection = FIREWIRE_CONNECTION_P2P;
 }
 
 FirewireRecorder::~FirewireRecorder() {
 
     if(isopen) {
-        VERBOSE(VB_GENERAL,QString("FireWire: releasing iec61883_mpeg2 object"));
+        VERBOSE(VB_GENERAL,QString("Firewire: releasing iec61883_mpeg2 object"));
         iec61883_mpeg2_close(fwmpeg);
-        if(fwchannel > -1) {
-              VERBOSE(VB_GENERAL,QString("FireWire: disconnecting channel %1").arg(fwchannel));
-	      iec61883_cmp_disconnect (fwhandle, fwnode | 0xffc0,
-                   raw1394_get_local_id (fwhandle), fwchannel, fwbandwidth);
+        if(fwconnection == FIREWIRE_CONNECTION_P2P && fwchannel > -1) {
+              VERBOSE(VB_GENERAL,QString("Firewire: disconnecting channel %1").arg(fwchannel));
+	      iec61883_cmp_disconnect (fwhandle, fwnode | 0xffc0, fwoplug,
+                   raw1394_get_local_id (fwhandle), fwiplug, fwchannel, fwbandwidth);
         }
-        VERBOSE(VB_GENERAL,QString("FireWire: releasing raw1394 handle"));
+        VERBOSE(VB_GENERAL,QString("Firewire: releasing raw1394 handle"));
         raw1394_destroy_handle(fwhandle);
     }    
     isopen = false;
@@ -63,7 +65,7 @@
      if(isopen)
          return true;
     
-     VERBOSE(VB_GENERAL,QString("FireWire: Initializing Port: %1, Node: %2, Speed: %3")
+     VERBOSE(VB_GENERAL,QString("Firewire: Initializing Port: %1, Node: %2, Speed: %3")
                                .arg(fwport)
                                .arg(fwnode)
                                .arg(FirewireSpeedString(fwspeed)));
@@ -74,13 +76,26 @@
          return false;
      }
 
-     fwchannel = iec61883_cmp_connect (fwhandle, fwnode | 0xffc0,
-                        raw1394_get_local_id (fwhandle), &fwbandwidth);
-
-     if(fwchannel > -1) {
-	VERBOSE(VB_GENERAL,QString("FireWire: Created Channel: %1, Bandwidth Allocation: %2").arg(fwchannel).arg(fwbandwidth));
+     if(fwconnection == FIREWIRE_CONNECTION_P2P) {
+          VERBOSE(VB_GENERAL,QString("Firewire: Creating P2P Connection with Node: %1").arg(fwnode));
+          fwchannel = iec61883_cmp_connect (fwhandle, fwnode | 0xffc0, &fwoplug, 
+                        raw1394_get_local_id (fwhandle), &fwiplug, &fwbandwidth);
+          if(fwchannel > -1) {
+	      VERBOSE(VB_GENERAL,QString("Firewire: Created Channel: %1, Bandwidth Allocation: %2").arg(fwchannel).arg(fwbandwidth));
+          }
+     } else {
+          VERBOSE(VB_GENERAL,QString("Firewire: Creating Broadcast Connection with Node: %1").arg(fwnode));
+          if(iec61883_cmp_create_bcast_output(fwhandle, fwnode | 0xffc0, 0, FIREWIRE_CHANNEL_BROADCAST, fwspeed) != 0) {
+	      VERBOSE(VB_IMPORTANT, QString("Firewire: Failed to create connection"));
+	      // release raw1394 object;
+              raw1394_destroy_handle(fwhandle);
+              return false;
+          }
+          fwchannel = FIREWIRE_CHANNEL_BROADCAST;
+          fwbandwidth = 0;
      }
 
+
      if((fwmpeg = iec61883_mpeg2_recv_init (fwhandle, read_tspacket, this)) == NULL) {
          VERBOSE(VB_IMPORTANT, QString("Firewire: unable to init iec61883_mpeg2 object, bailing"));
          perror("iec61883_mpeg2 object");
@@ -94,7 +109,7 @@
      // probably shouldnt even allow user to set, 100Mbps should be more the enough
      int curspeed = iec61883_mpeg2_get_speed(fwmpeg);
      if(curspeed != fwspeed) {
-         VERBOSE(VB_GENERAL,QString("FireWire: Changing Speed %1 -> %2")
+         VERBOSE(VB_GENERAL,QString("Firewire: Changing Speed %1 -> %2")
                                     .arg(FirewireSpeedString(curspeed))
                                     .arg(FirewireSpeedString(fwspeed)));
          iec61883_mpeg2_set_speed(fwmpeg, fwspeed);
@@ -214,6 +229,12 @@
             VERBOSE(VB_IMPORTANT, QString("Firewire: Invalid speed '%1', assuming 0 (100Mbps)").arg(fwspeed));
             fwspeed = 0;
         }
+    } else if(name == "connection") {
+	fwconnection = value;
+	if(fwconnection != FIREWIRE_CONNECTION_P2P && fwconnection != FIREWIRE_CONNECTION_BROADCAST) {
+	    VERBOSE(VB_IMPORTANT, QString("Firewire: Invalid Connection type '%1', assuming P2P").arg(fwconnection));
+            fwconnection = FIREWIRE_CONNECTION_P2P;
+        }
     }
 }
 
Index: libs/libmythtv/firewirerecorder.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/firewirerecorder.h,v
retrieving revision 1.1
diff -u -r1.1 firewirerecorder.h
--- libs/libmythtv/firewirerecorder.h	2 Feb 2005 07:11:10 -0000	1.1
+++ libs/libmythtv/firewirerecorder.h	6 Mar 2005 02:50:50 -0000
@@ -16,6 +16,11 @@
 
 #define FIREWIRE_TIMEOUT 15
 
+#define FIREWIRE_CONNECTION_P2P		0
+#define FIREWIRE_CONNECTION_BROADCAST	1
+
+#define FIREWIRE_CHANNEL_BROADCAST	63
+
 class FirewireRecorder : public DTVRecorder
 {
   public:
@@ -36,7 +41,8 @@
     QString FirewireSpeedString(int speed);
 
   private:
-    int fwport, fwchannel, fwspeed, fwbandwidth, fwfd;
+    int fwport, fwchannel, fwspeed, fwbandwidth, fwfd, fwconnection;
+    int fwoplug, fwiplug;
     QString fwmodel;
     nodeid_t fwnode;
     raw1394handle_t fwhandle;
Index: libs/libmythtv/tv_rec.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/tv_rec.cpp,v
retrieving revision 1.173
diff -u -r1.173 tv_rec.cpp
--- libs/libmythtv/tv_rec.cpp	28 Feb 2005 02:28:11 -0000	1.173
+++ libs/libmythtv/tv_rec.cpp	6 Mar 2005 02:50:50 -0000
@@ -653,6 +653,7 @@
         nvr->SetOption("node", firewire_options.node);
         nvr->SetOption("speed", firewire_options.speed);
         nvr->SetOption("model", firewire_options.model);
+        nvr->SetOption("connection", firewire_options.connection);
         nvr->Initialize();
 #endif
         return;
@@ -1073,7 +1074,7 @@
                   "dvb_wait_for_seqstart,dvb_dmx_buf_size,"
                   "dvb_pkt_buf_size, skipbtaudio, dvb_on_demand,"
                   "firewire_port, firewire_node, firewire_speed,"
-                  "firewire_model "
+                  "firewire_model, firewire_connection "
                   "FROM capturecard WHERE cardid = :CARDID ;");
     query.bindValue(":CARDID", cardnum);
 
@@ -1121,6 +1122,7 @@
         test = query.value(16).toString();
         if (test != QString::null)
             firewire_opts.model = QString::fromUtf8(test);
+	firewire_opts.connection = query.value(17).toInt();
     }
 
     query.prepare("SELECT if(startchan!='', startchan, '3') "
Index: libs/libmythtv/tv_rec.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/tv_rec.h,v
retrieving revision 1.62
diff -u -r1.62 tv_rec.h
--- libs/libmythtv/tv_rec.h	23 Feb 2005 05:04:36 -0000	1.62
+++ libs/libmythtv/tv_rec.h	6 Mar 2005 02:50:51 -0000
@@ -45,6 +45,7 @@
     int port;
     int node;
     int speed;
+    int connection;
     QString model;
 } firewire_options_t;
 
Index: libs/libmythtv/videosource.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videosource.cpp,v
retrieving revision 1.69
diff -u -r1.69 videosource.cpp
--- libs/libmythtv/videosource.cpp	23 Feb 2005 19:39:19 -0000	1.69
+++ libs/libmythtv/videosource.cpp	6 Mar 2005 02:50:51 -0000
@@ -864,6 +864,16 @@
         }
 };
 
+class FirewireConnection: public ComboBoxSetting, public CCSetting {
+    public:
+       FirewireConnection(const CaptureCard& parent):
+       CCSetting(parent, "firewire_connection") {
+            setLabel(QObject::tr("Firewire Connection Type"));
+            addSelection(QObject::tr("Point to Point"),"0");
+            addSelection(QObject::tr("Broadcast"),"1");
+        }
+};
+
 class FirewirePort: public LineEditSetting, public CCSetting {
     public:
 	FirewirePort(const CaptureCard& parent):
@@ -911,6 +921,7 @@
         parent(a_parent) {
         setUseLabel(false);
         addChild(new FirewireModel(parent));
+        addChild(new FirewireConnection(parent));
         addChild(new FirewirePort(parent));
         addChild(new FirewireNode(parent));
         addChild(new FirewireSpeed(parent));


More information about the mythtv-dev mailing list