Monday, March 14, 2011

Compiling latest svn of XBMC for Nvidia Hardware.

The svn ppa does not get updated too often so sometimes it is nice to be able to build your own svn from source. I will try and explain the simplest method of achieving this.

First add the svn ppa:
sudo add-apt-repository ppa:team-xbmc-svn/ppa

Next fetch the essential build tools and all of XBMC's required libraries and headers:
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get build-dep xbmc


The next step is to get the latest source code for the most recent svn. To do this subversion must be installed, and can be done so by running:
sudo apt-get install subversion

Then checkout the latest svn source code by executing:
cd $HOME
svn co https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/ xbmc

The above command will place a copy of the source code in a directory named "xbmc" in the home directory.

Within the xbmc directory that the source code is contained, run the following commands in order to compile it:
./bootstrap
./configure --enable-vdpau --disable-pulse --disable-crystalhd
make -j2
make -C lib/addons/script.module.pil
make -C lib/addons/script.module.pysqlite
sudo make install

Replace the number 2 with the number of cores in your processor.

Now make a backup of the original XBMC install, and make the recently compiled version the default one to boot.
sudo mv /usr/bin/xbmc /usr/bin/xbmc.bak
sudo mv /usr/bin/xbmc-standalone /usr/bin/xbmc-standalone.bak
sudo ln -s /usr/local/bin/xbmc /usr/bin/xbmc
sudo ln -s /usr/local/bin/xbmc-standalone /usr/bin/xbmc-standalone


Almost done, reboot:
sudo reboot

Reinstall nVidia Drivers:
sudo apt-get install --reinstall nvidia-current nvidia-current-modaliases nvidia-settings

Sunday, March 13, 2011

My Zotac ZBOX ND22 Setup.

Mission:

  1. Setup XBMC.
  2. Configure XBMC to run Headless for the purpose of remote administration.
  3. Configure XBMC, to do 24p and 60p using VDPAU.
  4. Enable WOL and Wake-on-Device.
  5. Setup Sound
  6. Configure XBMC to down convert DTS to AC3.(LG LE5300 does DD AC3 pass through.)
Introduction:

Currently my ZBOX is connected to an LG LE 5300 via HDMI. This LED TV is capable of outputting AC3 through it's optical out, which is convenient if your receiver has only one optical input. In the hopes of achieving the best media experience possible, I wanted to install XBMC and attain what was outline in the mission. The following will detail, how each of the five requirements were achieved and some tidbits and pointers that were picked up along the way.

Setting up XBMC:

  1. Download latest live cd.
  2. Download latest version of unetbootin.
  3. Format USB Key, using FAT 32 with Default Allocation size.
  4. Setup USB key with Live Image using unetbootin.
  5. Boot off usb, and follow the onscreen instructions to install XBMC onto the hard disk
source: http://www.mini-itx.com/projects/xbmc-ion/

Configure XBMC to Run Headless, and use 24p and 60p using VDPAU:

These two step are in the section, because both goals can be achieved be properly configuring you xorg.conf

Clean xorg.conf: sudo nvidia-xconfig

Stop X and XBMC: sudo stop xbmc-live

Next we need to query the TV for the EDID info for supported resolutions by starting X in verbose:  sudo X -verbose 6 > ~/xlog.txt 2>&1

The resulting xlog.txt file should contain lines that look similar to this:

(II)NVIDIA(0): Mode Validation Overrides for LG Electronics LG TV (DFP-1):
(II)NVIDIA(0): NoHorizSyncCheck
(II)NVIDIA(0): NoVertRefreshCheck
(II)NVIDIA(0): NoVesaModes
(II)NVIDIA(0): NoXServerModes
(II)NVIDIA(0): Frequency information for LG Electronics LG TV (DFP-1):
(II)NVIDIA(0): HorizSync : 31.000-82.000 kHz
(II)NVIDIA(0): VertRefresh : 57.000-63.000 Hz
(II)NVIDIA(0): (HorizSync from EDID)
(II)NVIDIA(0): (VertRefresh from EDID)
(II)NVIDIA(0):
(II)NVIDIA(0): --- Building ModePool for LG Electronics LG TV (DFP-1) ---
(II)NVIDIA(0): Validating Mode "1920x1080":
(II)NVIDIA(0): 1920 x 1080 @ 60 Hz
(II)NVIDIA(0): For use as DFP backend.
(II)NVIDIA(0): Mode Source: EDID
(II)NVIDIA(0): Pixel Clock : 148.50 MHz
(II)NVIDIA(0): HRes, HSyncStart : 1920, 2008
(II)NVIDIA(0): HSyncEnd, HTotal : 2052, 2200
(II)NVIDIA(0): VRes, VSyncStart : 1080, 1084
(II)NVIDIA(0): VSyncEnd, VTotal : 1089, 1125
(II)NVIDIA(0): H/V Polarity : +/+
(II)NVIDIA(0): Mode is valid.

The above lines will allow us to compose ModeLines, so that we may avoid the device querying for the information. If the device is setup to query for the information and the TV is not ON when the system is powered, it will never finish initializing the Nvidia card thus hanging the system and hampering our ability to run headless.

The resulting ModeLine should be:
ModeLine "1920x1080@60" 148.50 1920 2008 2052 220 1080 1084 1089 1125 +hsync +vsync
And the actual calculated refresh rate will be: 60 = 148, 500, 000 / 2200 / 1125

Now that we can convert the EDID info to ModeLines we can start editing our xorg.conf file. First insert a Monitor Section that looks similar to this:

Section "Monitor"
Identifier "Monitor0"
VendorName "LG Electronics"
ModelName "LG TV LE5300"
Option "DPMS"
HorizSync 31 - 82
VertRefresh 57 - 63
ModeLine "1920x1080@60" 148.35 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync
ModeLine "1920x1080@24" 74.16 1920 2558 2602 2750 1080 1084 1089 1125 +hsync +vsync
ModeLine "1920x1080@30" 89.01 1920 2448 2492 2640 1080 1084 1089 1125 +hsync +vsync
EndSection

Replace HorizSync, VertRefresh and each ModeLine with your own information.

Next, the Screen Section needs to be edited so that it closely resembles the following:
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1920x1080@60" "1920x1080@24" "1920x1080@30"
EndSubSection
Option "ExactModeTimingsDVI" "true"
EndSection

Ensure the name of the Modes matches the names of the ModeLines. Please note the absence of: Option "UseEDID" "FALSE" the reason this line is nowhere to be found in our xorg.conf file is because it disables audio over the HDMI. Instead a variation of the following three lines are used:

Option "UseEdidFreqs" "false"
Option "UseEdidDpi" "false"
Option "ModeValidation" "NoEdidModes"


According to Nvidia the above three lines is equal to using Option "UseEDID" "FALSE", but with sound still working. The other options exercised in the "ModeValidation" line will completely disable the system's reliance on EDID and more importantly the TV being on.

My full xorg.conf.

Sources: http://www.wieslander.eu/wiki/index.php?title=Xbmc, http://www.mentby.com/jean-yves-avenard/mythtv-024-hdmi-audio-problem.html, http://www.nvnews.net/vbulletin/showthread.php?t=121185, http://ubuntuforums.org/showthread.php?t=1003099&page=2

Setup Sound:
In "/etc/modprobe.d/" create a file named snd_hd_intel.conf with the following line:


Then run alsamixer and unmute all spidf channels. Then create a file named asound.conf in "/etc/" the file should look as follows:

The asound.conf file will enable the XBMC system sounds. If using the standard drivers included with live (195) be aware they have issues with system sounds not working after playback.


Configure XBMC to convert DTS to AC3 5.1 when using HDMI:

Go to Audio Output settings and enable the following options:

Audio Output: Optical/Coax
Speaker Configuration: 5.1
Boost Volume Level On Downmix: Enable
Dolby Digital (AC3) Capable Receiver: Enable
DTS Capable Receiver: Disabled
Audio Output Device: HDMI
Passthrough Output Device: HDMI

Enable WOL and Wake-on-Device:


Do not make any changes within the bios, it has been my findings that the optimal settings have produce the best results. Next edit /etc/network/interface so that the following line is added "ethernet-wol g" like in the example below:


On the ND22 to enable Wake-On-Usb, I edited "/etc/rc.local" to look as follows:


Edit "/etc/default/grub" file so that it looks similar to the following:

Notice how the following options were added, this is very important:
usbcore.autosuspend=-1 acpi_enforce_resource=lax
to the GRUB_CMDLINE_LINUX_DEFAULT line. Once you have done so as well, then update grub running:sudo update-grub

Sources: http://wiki.xbmc.org/?title=Enable_Wake-On-Device, http://www.mythtv.org/wiki/Wake-on-LAN


Tidbits:

Installing newest Nvidia drivers:
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current nvidia-current-modaliases nvidia-settings


Nvidia drivers need reinstalling occasionally when xbmc is updated this can be done using the following command:
sudo apt-get install --reinstall nvidia-current nvidia-current-modaliases nvidia-settings

Removing Nvidia Drivers:
sudo apt-get --purge remove nvidia-current nvidia-settings nvidia-current-modaliases