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@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

Reply via email to