Sony XL1B2

From MythTV Official Wiki
Revision as of 17:11, 11 January 2009 by Nodedog (talk | contribs)

Jump to: navigation, search

A Firewire 200-DVD changer with a double-layer burner. Does MythTV or Linux support this device?

Document.png - Specs {{{2}}}

It is possible to use this unit with Linux and MythTv, several patches have been developed or are under development to fully support this unit. I encourage anyone who is interested to ask about this device on the appropriate mailing list(s) and to add any relevant feature requests so that this device and perhaps other similar ones can be supported properly.

To get this device working you will need to ensure that ieee1394, sbp2, scsi changer and scsi cd rom/dvd support are enabled in your Kernel. If all is well then the unit will appear as 2 scsi devices 1 changer device and 1 scsi cdrom /dvd device e.g. /dev/sg2 and /dev/sr0. It is also possible to create a udev rule to give the changer a suitable symlink, the changer is a type8 sg device. Although I have experienced issues with mtx locking up when this is created after bootup.

The mtx command is used to control the changer, MythTv and other application can use this command to change discs. You will currently need a patch for mtx in order for it to work correctly with the Sony VAIO media changer, you can ask for this on the mtx mailing list at http://sourceforge.net/mail/?group_id=4626. This patch also adds some feedback to stdout in order to help integration with other applications. When working correctly the device will show something like the following


# mtx -f /dev/sg2 altquerymode status
 Storage Changer /dev/sg2:1 Drives, 201 Slots ( 1 Import/Export ) Data Transfer Element 0:Empty
     Storage Element 1 IMPORT/EXPORT:Empty
     Storage Element 2:Full
     Storage Element 3:Empty
......
     Storage Element 200:Empty
     Storage Element 201:Empty

Support for the changer is now available in the latest mtx although it uses a slightly different syntax than above.

Support for batch CD ripping, changer inventory and playback of loaded DVDs in MythVideo have been added to my local copy of myth, although this support is very preliminary it has been tested and does work correctly. The jobs are currently offloaded to mtd and run in the background. It should also be possible to support multiple changers or changers other than the Sony utilising these patches. Please ask on the appropriate Myth mailing lists if any details are required I will do my best to help (alternately you can try nodenet at hotmail dot com, although you may be filtered as spam :) ). It will also be possible to add support for MythArchive and batch DVD ripping in a similar manner.

It's worth noting that currently when batch ripping CDs if a faulty disc is encountered, the device may become disabled and unresponsive. A patch for this has been submitted (to sbp2) that allows the device to recover and has removed the need for a reboot when this problem occurs, it is of course still possible that the ripping process may try and read a faulty disc indefinitely if there is a problem. You can ask for this patch at https://lists.sourceforge.net/lists/listinfo/linux1394-devel

It may also be useful to use the regionset utility to set the region code of the changer drive if you are not in region 1 (current default).

Scripts

It is possible as an alternative to modifying mythtv to use scripts to load / unload the changer. A suitable approach may be something like the following

  • Create a stub file with a unique file extension for each dvd changer slot
    • You could use mtx output to create them for only the loaded slots
    • The stub file needs to convey the appropriate information to load / unload the correct slot
  • Configure mythtv to recognise the file extension as a video file and write an appropriate wrapper script to load / play the dvd.

This approach should have the advantage of working with a standard mythtv release. You should still be able to enter meta data against your stub files. The scripts below should help with this, I don't have an inventory script unfortunately as the inventory I use was created with the original patched version of mtd using mysql tables. However as the approach is similar I feel the above should still work.

The scripts below were created using the patched mtx, the syntax will be different now. They are currently used with ssh to allow the front end to load / unload the desired disc.

mythdvdchangerload.sh

#!/bin/bash

#chng=`dmesg | grep  -e 'ch .*sg[0-9] type 8' | tail -1 |  sed -e 's/.*\(sg[0-9]\).*/\/dev\/\1/'`
#the above can be used to find most recent device no of changer

#udev rules now creates ch0 for type8 sg device
#chng=/dev/ch0
#symlink only works if changer connected b4 power on of server otherwise causes mtx to lock up
chng=`ls -l /dev/ch0 | sed -e 's/.*\(sg[0-9]\).*/\/dev\/\1/'`

if /usr/local/sbin/mtx -f $chng altquerymode drivestatus | grep -q "Slot: Empty"
then
   echo "Good!...Changer drive is empty"
else
   echo "Changer is still loaded.... attempting to unload drive"

   if /usr/bin/eject -v /dev/sr0 | grep -q "eject command succeeded"
   then
      echo "Eject command succeeded (drive spindown)"
   else
      exit 0
   fi

   /usr/local/sbin/mtx -f $chng altquerymode unload

   if /usr/local/sbin/mtx -f $chng altquerymode drivestatus | grep -q "Slot: Empty"
   then
      echo "Good!...Changer drive is now empty"
   else
      echo "Error: Changer is still loaded...aborting"
      exit 0
   fi
fi

if /usr/local/sbin/mtx -f $chng altquerymode load $1 | grep -q "Status: OK"
then
   echo "Slot $1 load succeeded...waiting 5 seconds for disc to settle"
   sleep 5
else
   exit 0
fi

exit 1


mythdvdchangerunload.sh

#!/bin/bash

# chng=`dmesg | grep  -e 'ch .*sg[0-9] type 8' | tail -1 |  sed -e 's/.*\(sg[0-9]\).*/\/dev\/\1/'`
#the above can be used to find most recent device no of changer

#udev rules now creates ch0 for type8 sg device
#chng=/dev/ch0
#symlink only works if changer connected b4 power on of server otherwise causes mtx to lock up
chng=`ls -l /dev/ch0 | sed -e 's/.*\(sg[0-9]\).*/\/dev\/\1/'`

if /usr/local/sbin/mtx -f $chng altquerymode drivestatus | grep -q "Slot: Empty"
then
   echo "Good!...Changer drive is empty"
else
   echo "Changer is still loaded.... attempting to unload drive"
 
   if /usr/bin/eject -v /dev/sr0 | grep -q "eject command succeeded"
   then
      echo "Eject command succeeded (drive spindown)"
   else
      exit 0
   fi

   /usr/local/sbin/mtx -f $chng altquerymode unload

   if /usr/local/sbin/mtx -f $chng altquerymode drivestatus | grep -q "Slot: Empty"
   then
      echo "Good!...Changer drive is now empty"
   else
      echo "Error: Changer is still loaded...aborting"
      exit 0
   fi
fi

exit 1

This is an example of a script that can be run from the front end to play a dvd using the changer. It is designed to work with a remote dvd changer. To make it work you would need to configure ssh to login without a password for the appropriate user. Xine would also need to be patched with the cdda_server patch and the cdda_server would of course need to be running on the remote machine. The xine -r syntax may be something which I added and may not be supported normally (I forget). I've found the cdda_server patch to be a bit chopy for dvd playback but perhaps other people will have more luck.

If the dvd changer is connected directly to your front end there is of course no need to use ssh and xine can be told to use your local dvd changer drive e.g. /dev/sr0 (hence no need for the cdda_server patch either).

mythplaydvdchangerslot.sh

ssh <user@dvdserver> /usr/local/bin/mythdvdchangerload.sh $1
xine -pq --no-splash -r anamorphic dvd://<dvdserver>:3050/
ssh <user@dvdserver> /usr/local/bin/mythdvdchangerunload.sh &