[mythtv] [patch] firewire internal channel change for dct-6200

Jim Westfall jwestfall at surrealistic.net
Tue Apr 19 06:11:06 UTC 2005


Hi

patch adds support for internal channel changing via firewire for DCT-6200 
and friends.

This adds a new library requirement of libavc1394 for firewire.

To enable you will need to set the firewire model in setup to DCT-6200 and 
unset the external channel changer option.

jim
-------------- next part --------------
Index: configure
===================================================================
RCS file: /var/lib/mythcvs/mythtv/configure,v
retrieving revision 1.54
diff -u -r1.54 configure
--- configure	18 Apr 2005 23:51:34 -0000	1.54
+++ configure	19 Apr 2005 05:07:08 -0000
@@ -1644,7 +1644,7 @@
 
 if test x"$firewire_cable_box" = x"yes" ; then
     firewire_cable_box="no"
-    if has_library libiec61883 ; then
+    if has_library libiec61883 -a has_library libavc1394 ; then
             firewire_cable_box="yes"
     fi
 fi
@@ -2280,7 +2280,7 @@
 if test x"$firewire_cable_box" = x"yes" ; then
   CCONFIG="$CCONFIG using_firewire"
   CONFIG_DEFINES="$CONFIG_DEFINES USING_FIREWIRE"
-  echo "CONFIG_FIREWIRE_LIBS=-lraw1394 -liec61883" >> config.mak
+  echo "CONFIG_FIREWIRE_LIBS=-lraw1394 -liec61883 -lavc1394" >> config.mak
 fi
 
 if test x"$lirc" = x"yes" ; then
Index: libs/libmythtv/firewirechannel.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/firewirechannel.cpp,v
retrieving revision 1.1
diff -u -r1.1 firewirechannel.cpp
--- libs/libmythtv/firewirechannel.cpp	2 Feb 2005 07:11:10 -0000	1.1
+++ libs/libmythtv/firewirechannel.cpp	19 Apr 2005 05:07:09 -0000
@@ -12,23 +12,69 @@
 class TVRec;
 
 
-FirewireChannel::FirewireChannel(TVRec *parent): ChannelBase(parent) {
+FirewireChannel::FirewireChannel(firewire_options_t firewire_opts, TVRec *parent): 
+    ChannelBase(parent),fw_opts(firewire_opts) {
+	
+    isopen = false;
     capchannels = 1;
+    fwhandle = NULL;
     channelnames[0] = "MPEG2TS";
+
+    if(externalChanger[currentcapchannel].isEmpty()) {
+
+       if(fw_opts.model == "DCT-6200") {
+          if((fwhandle = raw1394_new_handle_on_port(fw_opts.port)) == NULL) {
+              VERBOSE(VB_IMPORTANT,QString("FireWireChannel: unable to get handle for port: %1").arg(fw_opts.port));
+              return;
+          }
+
+          VERBOSE(VB_GENERAL,QString("FireWireChannel: allocated raw1394 handle for port %1").arg(fw_opts.port));
+          isopen = true;
+       } else {
+          VERBOSE(VB_IMPORTANT,QString("FireWireChannel: internal channel changer only supported by DCT-6200 models"));
+       }
+    }
 }
 
 FirewireChannel::~FirewireChannel(void)
-{   
+{
+
+    if(isopen) {
+        VERBOSE(VB_GENERAL,QString("FireWireChannel: releasing raw1394 handle"));
+        raw1394_destroy_handle(fwhandle);
+    }
+
 }
 
 bool FirewireChannel::SetChannelByString(const QString &chan) {
 
+     int dig[3];
+     int channel = chan.toInt();
+     quadlet_t cmd[2];
 
      inputChannel[currentcapchannel] = chan;
      curchannelname = chan;
 
      if (externalChanger[currentcapchannel].isEmpty()) {
-         VERBOSE(VB_IMPORTANT,QString("FireWire: external channel changer only supported at this time.")); 
+         dig[2] = channel % 10;
+         dig[1] = (channel % 100) / 10;
+         dig[0] = (channel % 1000) / 100;
+
+         if(isopen && fw_opts.model == "DCT-6200") {
+            VERBOSE(VB_GENERAL,QString("FireWireChannel: channel:%1%2%3 cmds: 0x%4, 0x%5, 0x%6").
+              arg(dig[0]).arg(dig[1]).arg(dig[2]).arg(DCT6200_CMD0 | dig[0], 0, 16).
+              arg(DCT6200_CMD0 | dig[1], 0, 16).
+              arg(DCT6200_CMD0 | dig[2], 0, 16));
+            for(int i = 0;i < 3 ;i++) {
+                cmd[0] = DCT6200_CMD0 | dig[i];
+                cmd[1] = 0x0;
+     
+                avc1394_transaction_block(fwhandle, fw_opts.node, cmd, 2, 1);
+                usleep(500000);
+            }
+         } else {
+            VERBOSE(VB_IMPORTANT,QString("FireWireChannel: internal channel changer only supported by DCT-6200 models"));
+         }
      } else if(!ChangeExternalChannel(chan)) {
          return false;
      }
Index: libs/libmythtv/firewirechannel.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/firewirechannel.h,v
retrieving revision 1.1
diff -u -r1.1 firewirechannel.h
--- libs/libmythtv/firewirechannel.h	2 Feb 2005 07:11:10 -0000	1.1
+++ libs/libmythtv/firewirechannel.h	19 Apr 2005 05:07:09 -0000
@@ -11,13 +11,24 @@
 #include <qstring.h>
 #include "tv_rec.h"
 #include "channelbase.h"
+#include <libavc1394/avc1394.h>
 
 using namespace std;
 
+// 6200 defines for channel changes, taken from contrib/6200ch.c
+#define AVC1394_SUBUNIT_TYPE_6200 	(9 << 19)  /* uses a reserved subunit type */ 
+#define AVC1394_6200_COMMAND_CHANNEL 	0x00007C00 /* 6200 subunit command */
+#define AVC1394_6200_OPERAND_SET 	0x00000020 /* 6200 subunit command operand */
+
+#define DCT6200_CMD0 AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_6200 | \
+        AVC1394_SUBUNIT_ID_0 | AVC1394_6200_COMMAND_CHANNEL | \
+        AVC1394_6200_OPERAND_SET
+
+
 class FirewireChannel : public ChannelBase
 {
  public:
-    FirewireChannel(TVRec *parent);
+    FirewireChannel(firewire_options_t firewire_opts, TVRec *parent);
     ~FirewireChannel(void);
 
     bool SetChannelByString(const QString &chan);
@@ -27,7 +38,11 @@
     void SwitchToInput(int newcapchannel, bool setstarting)
                       { (void)newcapchannel; (void)setstarting; }
     void SetExternalChanger(void);
-
+private:
+    firewire_options_t fw_opts;
+    nodeid_t fwnode;
+    raw1394handle_t fwhandle;
+    bool isopen;
 };
 
 #endif
Index: libs/libmythtv/tv_rec.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/tv_rec.cpp,v
retrieving revision 1.180
diff -u -r1.180 tv_rec.cpp
--- libs/libmythtv/tv_rec.cpp	3 Apr 2005 16:42:10 -0000	1.180
+++ libs/libmythtv/tv_rec.cpp	19 Apr 2005 05:07:09 -0000
@@ -126,7 +126,7 @@
     else if (cardtype == "FIREWIRE")
     {
 #ifdef USING_FIREWIRE
-        channel = new FirewireChannel(this);
+        channel = new FirewireChannel(firewire_options, this);
         channel->Open();
         if (inputname.isEmpty())
             channel->SetChannelByString(startchannel);
Index: libs/libmythtv/videosource.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videosource.cpp,v
retrieving revision 1.76
diff -u -r1.76 videosource.cpp
--- libs/libmythtv/videosource.cpp	13 Apr 2005 22:58:08 -0000	1.76
+++ libs/libmythtv/videosource.cpp	19 Apr 2005 05:07:10 -0000
@@ -856,6 +856,7 @@
  	CCSetting(parent, "firewire_model") {
             setLabel(QObject::tr("Firewire Model"));
             addSelection(QObject::tr("Other"));
+            addSelection(QObject::tr("DCT-6200"));
             setHelpText(QObject::tr("Firewire Model is for future use in case "
                                     "there is a need to model specific "
                                     "workarounds.")); 


More information about the mythtv-dev mailing list