FireWire

From MythTV Official Wiki
Revision as of 20:22, 21 April 2006 by Kormoc (Talk | contribs)

Jump to: navigation, search


FireWire (also known as i.Link or IEEE 1394) is a personal computer and digital video serial bus interface standard offering high-speed communications and isochronous real-time data services. FireWire can be considered a successor technology to the obsolescent SCSI Parallel Interface. Up to 63 devices can be daisy-chained to one FireWire port.

FireWire works very well in connecting a MythTV backend to certain cable boxes (including the Motorola DCT-6200). MythTV 0.18 and up contains built-in support for changing channels on the DCT-6200 (generally reliable, although occasionally digits get dropped). Contained in this is information on how to get a fully working firewire setup going either with a single set top box or using daisy chain. How to get started:

Dependencies

  • '--enable-firewire' when building mythbackend.
  • libraw1394
  • libavc1394
  • libiec61883

Modules

You will need to have ieee1394 and ohci1394 loaded, which should end up giving you

mythbox:~# lsmod|grep 1394
dv1394                 20728  0
raw1394                25120  2
eth1394                19856  0
ohci1394               32716  1 dv1394
ieee1394              353144  4 dv1394,raw1394,eth1394,ohci1394

Once these are loaded connect your cable box and run plugreport, you should see something along the lines of

mythbox:~# plugreport
Host Adapter 0
==============

Node 0 GUID 0x0010dc000099e920
------------------------------
libiec61883 error: error reading oMPR
libiec61883 error: error reading iMPR

Node 1 GUID 0x20e999000099e920
------------------------------
libiec61883 error: error reading oMPR
libiec61883 error: error reading iMPR

Node 2 GUID 0x000e5cfffed720aa
------------------------------
oMPR n_plugs=1, data_rate=2, bcast_channel=63
oPCR[0] online=1, bcast_connection=0, n_p2p_connections=0
        channel=63, data_rate=2, overhead_id=0, payload=376
iMPR n_plugs=0, data_rate=2

Obviously the node and host will vary depending on your setup.

Whats important though is to note which Host and Node your cable box(es) is(are) connected to.

MythTV Setup

Now in mythtv-setup create the new capture device using firewire. Enter the Host/Node information (Myth tries to auto-detect this but its not fool proof, so sanity check it). Set it to Broadcast and 400MBPS. Once the capture device is setup assign a lineup and exit mythtv-setup.

DCT62xx Channel Changes

There are currently two methods known for changing channels on the Motorola DCT62xx series cable boxes. One is employed by MythTV's internal tuning code, the other requires use of the 6200ch program in the contrib/ folder of the MythTV source. If the internal tuning does not work well you can set MythTV to use 6200ch in mythtv-setup. 6200ch has a few options,

Usage: 6200ch [-v] [-s] [-n NODE] [-p PORT] <channel_num>
-v        print additional verbose output
-s        use single packet method
-n NODE   node to start device scanning on (default:1)
-p PORT   port/adapter to use              (default:0)

make sure to put the correct Node and Port(Host) for the box you wish to control. The -s option is the second tuning method to try.

Watch TV

Now you're ready to watch TV!

5C, Digital Rights Management

Firewire connections employ a content protection system commonly known as 5C. 5C is part of DTCP and is broadcast with digital television transmissions. Basically the device tuning the channel talks to the devices connected to it via firewire and if it does not get a proper response it will not transmit the signal to the device. Any device capable of receiving a 5C "encrypted" signal may not then send it off to a non-5C device, so needless to say the 5C hardware and licensing is expensive and complicated.

The point is, most cable company's use 5C to "protect their content", so don't expect to be able to tune in to many if any channels using this method. The only channels they are required by the FCC to leave unprotected are the analog OTA channels which does not include OTA HDTV stations!

So the cable companys set the 5C flag to 0, which is essentially turning it off, for these analog OTA stations, and many will also set channels that can be tuned without a cable box to 5C=0 as well. So when testing tune to an analog OTA station (like your local ABC, CBS, NBC, or FOX stations), then from there you can see what other channels your able to stream via firewire.

DCT62xx

The Motorola DCT62xx series boxes have a service menu that will tell you what the 5C setting is for the currently tuned channel. Here's how you do it...

  1. Tune to the channel in question
  2. Turn the box off
  3. Immediately press the menu button on the box or remote.
  4. Use the arrows to select d11
  5. Read what the value is for 5C

Anything other than 0 means 5C is enabled for that channel.

Troubleshooting

If you are tuning a 5C=0 station and MythTV is not consist in grabbing the mpeg stream you should trying shutting down the computer and unplugging the cable box power and disconnect the firewire cable from one end. Once both are powered down turn them all back on and reconnect the firewire cable. This should reset/clear any firewire plug settings and allow Myth to properly set them.

MythTV will change the firewire plug settings when it begins streaming to whatever you have set in mythtv-setup. Since the firewire connection for the cable boxes should be Broadcast theres really no point in using P2P.

Finally, there is a bug in the linux kernel that causes some firewire chips/setups (?) to overflow their buffer and cause excessively high CPU usage. There was a bug in MythTV itself but I believe it has been patched(?). The bug though will cause dropped data in the mpeg stream resulting in many errors during playback.

SlicerDicer's Method

This is the method SlicerDicer and a bunch of irc folks used to get SlicerDicer's cable box working correctly, in a daisy chain loop (one firewire port, 3 tuners).

Advised kernel setup

I would highly advise doing the kernel with the 1394 built in not modules to eliminate issues with modprobe. Kernels are quite easy to build and its never a bad idea to learn how.

  • Location of Firewire Support in the Kernel in 2.6.15.1 vanilla-sources
> device drivers > IEEE 1394 (FireWire) support
  │ │ ---   Subsystem Options                                             │ │
  │ │ [ ]   Excessive debugging output                                    │ │
  │ │ [ ]   OUI Database built-in                                         │ │
  │ │ ---   Build in extra config rom entries for certain functionality   │ │
  │ │ ---     IP-1394 Entry                                               │ │
  │ │ [*]   Export all symbols of ieee1394's API                          │ │
  │ │ ---   Device Drivers                                                │ │
  │ │ ---   Texas Instruments PCILynx requires I2C                        │ │
  │ │ <*>   OHCI-1394 support                                             │ │
  │ │ ---   Protocol Drivers                                              │ │
  │ │ <*>   OHCI-1394 Video support                                       │ │
  │ │ < >   SBP-2 support (Harddisks etc.)                                │ │
  │ │ <*>   Ethernet over 1394                                            │ │
  │ │ <*>   OHCI-DV I/O support                                           │ │
  │ │ <*>   Raw IEEE1394 I/O support                                      │ │
  │ │ <*>   IEC61883-1 Plug support                                       │ │
  │ │ <*>     IEC61883-6 (Audio transmission) support                     │ │
  • Note: IEC61883 support was removed from kernel after 2.6.15 to allow for userland operation.

Plugctl

Various switches include -n -p and options to use are oMPR, iMPR, oPCR[n]

  • Below is my plugreport "I removed some data due to it being bogus"
Host Adapter 0
==============

Node 1 GUID 0x00159afffeccac5f
------------------------------
oMPR n_plugs=1, data_rate=2, bcast_channel=63
oPCR[0] online=1, bcast_connection=0, n_p2p_connections=1
        channel=0, data_rate=2, overhead_id=0, payload=376
iMPR n_plugs=0, data_rate=2

Node 2 GUID 0x00159afffeccbf56
------------------------------
oMPR n_plugs=1, data_rate=2, bcast_channel=63
oPCR[0] online=1, bcast_connection=0, n_p2p_connections=1
        channel=1, data_rate=2, overhead_id=0, payload=376
iMPR n_plugs=0, data_rate=2

As you will notice in the above you have options to set oMPR, oPCR, iMPR

If you wish to modify these values as I have for my current daisy chain you can do so. Before I go further I will explain how each thing is done in my config above that should be more than enough to get going. As per my settings I was unable to use broadcast or bcast_connection so I was forced to come up with a solution for Point to Point or n_p2p_connections, notice they are both set to a value of '1' this gives me a very reliable and stable connection but setting them both to '1' would cause the transmission to overlap and corrupt the video files. This is where the idea of using seperate channels came into play. As node '1' is set to channel '0' node 2 is set to channel '1' this prevents transmission overlap. This means you can run 2 independent boxes by daisy chain. If your running a single box this should not be needed.

As by default your n_p2p_connections will be set to '0' and this causes a problem with all of my dct6200's, this makes it so I am unable to watch livetv with any form of reliablity nor am I able to record. Its a good idea to change these settings with the following commands. They can be issued in your /etc/init.d/ script by creating a new one as I did or add it to your current one. These commands cannot be issued by cron as it will cause it to give values that are not correct.

To explain what the switch's do for plugctl, -n will allow you to specify your node and -p will allow you to specify your host adapter. If you are using host adapter 0 then there is no need to use the -p switch.

Onto the commands to enter to the terminal or your /etc/init.d/ scripts. Keep in mind with these you must modify them accordingly if you are using node '0' change to '-n 0' and if you are using host adapter 1 and node 1 change to '-n 1 -p 1' and it should work

> plugctl -n 1 oPCR[0].n_p2p_connections=1

This will allow setting it so you maintain a stable connection. If running a single set top box this is all that will needed. If running a daisy chain I cannot stress this hard enough but things are required to be done in a special order or it will not work. To daisy chain the dct6200 just plug the firewire cable into the back of one port and into the computer then the second free firewire port plug from one set top box to the other.

> plugctl -n 1 oPCR[0].channel=0
> plugctl -n 1 oPCR[0].n_p2p_connections=1
> plugctl -n 2 oPCR[0].channel=1
> plugctl -n 2 oPCR[0].n_p2p_connections=1

This should conclude the plugctl configuration and you can chose how you wish to do it, I would highly advise against cron as it lead me to nothing but trouble.

Test-mpeg2

This tool is very simple to use and at first glance is never a good idea to assume things are working. As said above with plugctl you can have your n_p2p_connections=0 set and it may work the first 3-5 trys but then it will start to fail. It would be a good idea on your part to test it at least 10 times. I tested it myself 50 times total to verify it was reliable.

  • If it is needed to use test-mpeg2, invoke the command I find it makes it easier to use it with .mpg vs .ts
> test-mpeg2 -r 1 > test.mpg

Mythtv-setup

When running mythtv setup you will want to set your capture device to firewire. Once you do this you should notice that you have options you can set. It should be pretty self explaining in regards to this. It seems that the default host adapter settings are 0 and node is set to 2. You will want to modify this to match your plugreport settings. Once modified you should have a working firewire system that should be very reliable.

Raw1394 udev

I ran into permissions issues with raw1394 and adding read permissions was just not enough. I had to specify that /dev/raw1394 be owned by mythtv:mythtv. To do this I did a custom udev rule.

  • Open a terminal and do the following
> nano /etc/udev/rules.d/10-raw.rules
  • Then enter the following information into the file being creating.
> KERNEL="raw[0-9]*",     NAME="%k", GROUP="mythtv", MODE="0666" OWNER="mythtv"

Closing notes

Setting up firewire to work with mythtv can be very complex if things are not done on a special order. Some people seem to hit the order just properly and do not have problems at all, then others will rip their head off to try to figure out what to do. I created this to help and hope it does, If needed help can be found in #mythtv-users.