Tuesday, December 01, 2009

HOWTO : MyGica D689 USB HDTV Dongle on Ubuntu 9.10

We can watch digital TV including HDTV on Ubuntu 9.10 with MyGica D689 USB HDTV dongle. You may also require to buy a new nVidia series 9000 or up display card. Since series 9000, nVidia display card supports hardware acceleration for playing HD video.

In order to keep my Ubuntu box easy for update and secure, I prefer to install software packages from official and PPA repositories. However, I need to compile the MyGica driver in order to make it works. Only gXine works out of box without compilation.

Hardware and software used in this tutorial :

CPU - AMD Athlon 64 x 2 4200+
RAM - 8GB DDR2 800
Hard Drive - 320GB x 2 on Hardware RAID 0
HDTV - MyGica D689 HDTV USB dougle (v3.0)
Display card - XFX nVidia GT240 with 1GB DDR3 RAM and HDMI
Operating system - Ubuntu 9.10 Desktop AMD64 with Kernel 2.6.31-16-generic

The following procedures are for installing PPA nVidia display driver.

Step 1 - Add essential repositories :

(A) Add medibuntu repository (for general multimedia codecs and plugins)

sudo wget http://www.medibuntu.org/sources.list.d/karmic.list --output-document=/etc/apt/sources.list.d/medibuntu.list &&
sudo apt-get -q update &&
sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring &&
sudo apt-get -q update


** Note : If you are using Ubuntu Samiux Remix, you are not required to add this repository as it is already added.

(B) Add nvidia-vdpau repository (for related VDPAU libraries)

echo "deb http://ppa.launchpad.net/nvidia-vdpau/ppa/ubuntu karmic main" | sudo tee -a /etc/apt/sources.list.d/nvidia-vdpau.list
echo "deb-src http://ppa.launchpad.net/nvidia-vdpau/ppa/ubuntu karmic main" | sudo tee -a /etc/apt/sources.list.d/nvidia-vdpau.list


Add key of nvidia-vdpau repository to the keyrings.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CEC06767

sudo apt-get update
sudo apt-get upgrade


** Remarks : Or, you can use this command
sudo sh -c 'echo "Test I want to write" > /path/to/file'

Step 2 - Install all related softwares, codecs and plugins :

sudo apt-get install x264 gxine gxineplugin mencoder mplayer-nogui

** Note : If you are using Ubuntu Samiux Remix, you are not required to install the following codecs and plugins.

sudo apt-get install ubuntu-restricted-extras quicktime-utils quicktime-x11utils libdvdnav4 libdvdread4 libdvdcss2 non-free-codecs faad

** Note : If you are using Ubuntu Samiux Remix, you may need to uninstall mplayer as it cannot work properly.

Then, reboot your system.

Step 3 - Install nVidia display driver

Select "System" - "Administration" - "Hardware driver" from the menu on the desktop.
Choose nVidia display driver 190 version as prompted. After the install, you are required to reboot your system.

After the reboot, you should install the following package.

sudo apt-get remove nvidia-settings
sudo apt-get install nvidia-settings-190


Step 3a - Alternative way to install nVidia display driver (Optional)

** Note : Choose Step 3 or 3a only but not both of them.

Uninstall the following package.

sudo apt-get remove nvidia-settings-190

Download the latest beta nVidia display driver 195.22 (as on 2009-11-28).

x86 version :
wget ftp://download.nvidia.com/XFree86/Linux-x86/195.22/NVIDIA-Linux-x86-195.22-pkg1.run

x86_64 version :
wget ftp://download.nvidia.com/XFree86/Linux-x86_64/195.22/NVIDIA-Linux-x86_64-195.22-pkg2.run

Install nVidia latest beta driver (195.22)

sudo apt-get remove nvidia-settings-190

sudo service gdm stop

It will go to command mode.

sudo sh NVIDIA-Linux-x86-195.22-pkg1.run

or

sudo sh NVIDIA-Linux-x86_64-195.22-pkg2.run

Follow the instructions on the screen to complete the installation.

sudo service gdm start

Reboot your system to make the driver activate.

For uninstall nVidia display driver :

sudo sh NVIDIA-Linux-x86_64-195.22-pkg2.run --uninstall
sudo sh NVIDIA-Linux-x86-195.22-pkg1.run --uninstall


** Note : If your kernel is updated, you should install the nVidia again.
** Note : Manual install of nVidia driver will overwrite some of the PPA's files. When you uninstall the driver, you need to reinstall the PPA's driver and libraries.

***The following procedure is for reinstall the PPA's driver after uninstalled manual installed official driver.

sudo service gdm stop
sudo apt-get --reinstall install nvidia-settings-190 nvidia-190-libvdpau nvidia-glx-190 nvidia-common nvidia-190-kernel-source xserver-xorg-video-nv nvidia-190-modaliases

sudo reboot


Download links for latest nVidia driver :

Download latest or beta x86 version
Download latest or beta x86_64 version

Then reboot your system.

Step 4 - Confirmation of VDPAU drivers are installed

Make sure "vdpau" is installed and activated.

ffmpeg -formats | grep vdpau

If you can see some vdpau displayed, vdpau works.

Step 5 - Install MyGica D689 driver :

sudo apt-get install mercurial

At you desired directory, such as /home/samiux.

mkdir mygica
cd mygica
hg clone http://bitbucket.org/davidtlwong/mygica_x8558pro
cd mygica_x8558pro


make
sudo make install


** Note : If you see an error of compiling FireDTV, you should do the following.

nano v4l/.config

Locate "CONFIG_DVB_FIREDTV=m" and change to "CONFIG_DVB_FIREDTV=n"

Save it and run "make" again.

make
sudo make install


Step 5a - Alternative way to install MyGica driver (Optional) :

** Note : Choose Step 5 or 5a only but not both of them.

Or, you can install this version. I prefer this version.

MyGica driver version used (Tip's version) :
Download Tip's version

wget http://bitbucket.org/davidtlwong/mygica_x8558pro/get/tip.tar.gz

tar -xvzf tip.tar.gz
cd mygica_x8558pro

make
sudo make install


** Note : If you see an error of compiling FireDTV, you should do the following.

nano v4l/.config

Locate "CONFIG_DVB_FIREDTV=m" and change to "CONFIG_DVB_FIREDTV=n"

Save it and run "make" again.

make
sudo make install


Tip's version changelog

Step 6 - Configure gXine :

Run gxine once and quit.

cd ~
nano .config/gxine/config

nano .config/gxine/channels.conf


Copy and paste the following :


inews:586000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_2_3:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:0:83
j2:586000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_2_3:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:0:82
jadehd:586000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_2_3:FEC_2_3:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:0:0:85
hdtv:602000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_1_2:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:0:12
atv13:602000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_1_2:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:0:13
ctiatv:602000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_1_2:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:0:14
cctv:602000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_1_2:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:0:15
jade:482000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_AUTO:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:811:0:1
pearl:482000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_AUTO:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:841:0:2
home:482000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_AUTO:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:111:0:11
world:482000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_AUTO:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:161:0:16


* This "channels.conf" is for HONG KONG only.
** The first entry of the "channels.conf" will be played once it is activated.

Then, copy the channels.conf to ".xine" directory.

cp .config/gxine/channels.conf .xine/channels.conf

Or, you can scan your own.

sudo apt-get install dvb-apps

scan /usr/share/dvb/dvb-t/hk-HongKong > channels.conf


Step 7 - Further configure gXine :

(A) Select "File" - "Configure" - "Perference" on the gXine control panel. Make changes as is.


gui : experience_level (Expert)

audio : a52 : dynamic_range (enabled)
audio : a52 : surround_downmix (enabled)
audio : a52 : level (200)
audio : volume : mixer_volume (100)
audio : volume : remember_volume (enabled)

media : dvb : tuning_timeout (3500)
media : dvb : remember_channel (disabled) *Enabled if you want
media : dvb : channels_conf (select .config/gxine/channels.conf)

engine : performance : memcpy_method (libc)
engine : buffers : video_num_buffers (519999)
engine : buffers : video_num_frames (50)


** Other settings be keep them untouched.

(B) Select "Audio" - "Configure Plugins" - "Audio Post-processing" on gXine control panel.

Add/Change "volnorm" - "properties" - "method" (1) and apply the change.

(C) Select "Video" - "Configure Plugins" - "Deinterlace" on gXine control panel.

Add/Change "tvtime" - "properties" - "method" (use_vo_driver) and apply the change.

(Ca) Select "Video" - "Configure Plugins" - "Deinterlace" on gXine control panel.

Add/Change "pp" - "properties" - "quality" (39) - "mode" (vb) and apply the change.

(Cb) Select "Video" - "Configure Plugins" - "Deinterlace" on gXine control panel.

Add/Change "pp" - "properties" - "quality" (39) - "mode" (ha) and apply the change.

(Cc) Select "Video" - "Configure Plugins" - "Deinterlace" on gXine control panel.

Add/Change "pp" - "properties" - "quality" (39) - "mode" (va) and apply the change.

*If you find video playback chopping, you should applied this setting. Step 7 (Ca) to (Cc) are useful for an old CPU.

(D) Select "Video" - "Configure Plugins" - "Video Post-processing" on gXine control panel.

Add/Change "tvtime" - "properties" - "method" (LinearBlend) and apply the change.

Step 8 - Watch HDTV :

Run gxine from the "Application" - "Mutimedia" - "gXine".

Click on "File" - "DVB" or "Playlist" to watch TV on gxine. If you just start the gXine, you should click "DVB".

(A) Watch HDTV :
On the control panel, select "Video" and uncheck "Post-processing" and check "DeInterlace". Otherwise, the video and sound cannot be synchronized.

e.g. Jade HD and aTV HD

(B) Watch Digital TV and Standard TV (analog) :
On the control panel, select "Video" and check "DeInterlace" and "Post-processing". Otherwise, the playback will be chopping.

Step 9 - Test your MyGica D689 (Optional) :

Insert your MyGica D689.

lsusb

The output should be :
Bus 001 Device 002: ID 0572:d811 Conexant Systems (Rockwell), Inc.

The following is for testing purpose.

sudo apt-get install dvbsnoop dvbtune

dvbsnoop -s signal

If there is some output but not error, your MyGica D689 works.

Step 10 - Streaming TV on LAN and recording TV programmes (Optional and not tested by me) :

This is work of "ksng".

Download ksng's scripts (dated 2009-NOV-26)
Download ksng's scripts (dated 2009-DEC-05)
Download ksng's scripts (dated 2010-FEB-04)

Known Issue :

(1) Make sure your signal strenght of digial TV is strong enough and your MyGica D689's antenna should be placed near or at the window. It is because signal strength detection does matter. Otherwise, your playback will be chopping and lagging as well as stuttering and distorting or even channels shifting. An amplifier is required at my area of testing.

(2) Xine decoder is coded by Xine team and the CPU power consumption is very high. Thus, more powerful CPU is required. The playback of HDTV (such as Jade HD and aTV HD) (1920x1080) is chopping under the testing hardware (Athlon 64x2 4200+ CPU). This CPU is launched around 2006. Another test with version 195.22 driver also has the same problem on my testing hardware.

**The chopping playback is solved by applied Step 7 (Ca)-(Cc). My Athlon 64x2 4200+ is too old to run the modern technology! The playback is just acceptable only.

(3) nVidia display driver version 190.42 does not support video post-processing and multi-threading. However, the beta driver (195.22 or later) may solved the multi-threading problems.

(4) Compiz runs flawless while watching HDTV, superise?!

(5) Mplayer (from official Ubuntu repository and nvidia-vdpau repository) does not work properly.

(6) Standard channels does not work properly at my side. May be the signal is not strong enough. However, when an amplifier is applied, the problem is solved.

(7) Me TV cannot record the TV programmes and HDTV may not play properly.

(8) When the kernel is updated, you need to delete the driver directory and build as well as re-install again.

Reference :

Please check HKEPC Forum (Linux) for updates (if any).

HKEPC Forum (Traditional Chinese, Hong Kong Forum)

Streaming HDTV scripts

Discussion on MyGica D689 (Traditional Chinese)

** Note : The links will be deleted when the time goes by.

Honor :

Many thanks to David T.L. WONG for the MyGica driver while "ksng" for the streaming scripts. They are active members of HKEPC Linux forum.

That's all. See you!