Unichrome On Fedora

Terry Barnaby - BEAM Ltd

22/11/04

Introduction

This page provides some basic information on getting the Via Unichrome drivers working under Fedora 2. Note that due to heavy development this could well be out of date by the time you read it. Hopefully soon these drivers will be part of the stock Fedora distribution.

Overview

The Unichrome Project provides open source support for the VIA/S3G Unichrome graphics controller. These controllers are found in the VIA Technologies CLE266, KM400/KN400, K8M800 and PM800/CN400 northbridges. My particular interest in the Via M10000 platform.

The updated stock Fedora 2 system has most of the drivers for these systems including the Via M10000 as part of the standard distribution. Note that there are some issues with kernels prior to 2.6.8-1.521, this is present on the standard CD ISO boot image. Thus you need an updated ISO CD boot image (or use network boot) in order to get the system installed the for first time. See the Fedora mail lists for more info. The main missing part is a decent X-Windows graphics driver. The Unichrome driver set provides the following main additional functionality:
  1. Via X-Windows graphics driver. This supports acceleration and TV out amongst other things.
  2. Hardware MPEG decoding through the libviaXvMC library for MythTv, xine and Mplayer.
  3. 3D graphics driver
  4. Kernel DRM module to support the above

Unichrome Components

There are four main components you need to get the driver set working:
  1. The X-Server Via driver module. This is in the the /usr/X11R6/lib/modules/drivers/via_drv.o. This provides X-Windows with access to the Via unichrome chipset and implements all Video mode setting and accelerated 2D graphics functions.
  2. The Kernel DRM module. This is in the file /lib/modules/2.6.8-1.521/kernel/drivers/char/drm/via.ko. This provides X-Windows and other graphics clients with direct access to the graphics hardware. It provides IO and memory mapping functions along with co-operative locks to allow client applications to directly access the graphics chip set. It is mainly used for 3D graphics output but is also used to access the hardware MPEG engine in the Unichrome chipset.
  3. The library libXvMC. This is in the file: /usr/X11R6/lib/libXvMC.so.1.0. This provides X-Windows clients with access to the hardware MPEG engine for MPEG display. Clients need to be built to use this library.
  4. The 3D graphics driver. I have not done much work with this as yet as my interest has been getting MythTv to display MPEG video for my TV.

Adding the RPM Unichrome drivers to a stock Fedora system

The simplest method is to use some pre-built binary RPM's which I have created to add the Unichrome drivers to a Fedora system. They are located at http://www.kingcot.eclipse.co.uk/unichrome/. These are based on a Unichrome snapshot and may be out of date, but they do work to a reasonable degree on my system. They, at least, should provide you with a starting point.

Building the Unichrome drivers from CVS

The other way is to build the drivers from the developers CVS trees. Note that as the CVS tree's are in continuous development and may be out of sync with one another you will need to play around with different CVS dated versions of the components until they will compile and work together.

I have put in specific dates for the CVS checkouts with the "-D <date>" option. These dates are for versions I know work together. To get the latest omit the "-D <date>" option.

The first to get and build is the DRM module. Basic sequence is:
  1. cvs -z3 -d:pserver:anonymous@dri.freedesktop.org:/cvs/dri login #(use Enter for the password)
  2. cvs -z3 -d:pserver:anonymous@dri.freedesktop.org:/cvs/dri co -D 2004-10-28 drm
  3. cd drm/linux-2.6; make
  4. cp via.ko /lib/modules/2.6.8-1.521/kernel/drivers/char/drm//via.ko (substitute kernel version as appropriate)
Now get and build the Unichrome X-Server driver and libXvMC. There is a description on how to do this at: http://sourceforge.net/docman/display_doc.php?docid=21910&group_id=102048.
Note: you will need to get and build the complete X-Server tree in order to be able to build the X-Server driver and libXvMC libraries.
Basic CVS commands to fetch the code are:
  1. cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/unichrome login #(use Enter for the password)
  2. cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/unichrome co -D 2004-10-28 -d via-drv xfree86
  3. cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/unichrome co -D 2004-10-28 -d via-libxvmc libxvmc
To simplify building the X-Server drivers, I have produced a simple Makefile that will download, setup and build the X-Windows system with the Via drivers. This is packaged in unichrome-build.tar.gz. To use:
  1. Download the unichrome-build.tar.gz  file.
  2. Untar the file into a suitable directory "tar -xzf unichrome-build.tar.gz"
  3. Follow the instructions at the top of the Makefile.

CVS Dates that work

See http://www.kingcot.eclipse.co.uk/unichrome for up to date info on CVS versions that work (for me .. ).

As of 2004-11-05

DRM
2004-11-05
Via X-Server driver
2004-11-05
Via XvMC library
2004-11-05

As of 2004-10-27

DRM
2004-10-27
Via X-Server driver
2004-10-28
Via XvMC library
2004-10-28

Optimisation

The standard X-Server Via driver uses polling to determine when the MPEG controller is ready for more data. This uses up CPU cycles and results in about 40% CPU usage for MPEG2 display. You can enable the AGP DMA with the "EnableAGPDMA" xorg.conf option to the driver to improve this to about 20% CPU usage. However this will break 3D usage at present.

Packages that make use of the Hardware MPEG decode

MythTv
This is a very good and quite polished Network TV viewer, PVR and more. I use it with a remote server containing the disk and two digital TV "Freeview" cards to provide digital TV viewing, video recoding, picture viewing etc for the TV and computers in my house. You currently need the CVS version to use Hardware MPEG decoding. I suspect that the 0.17 release will contain this. Info on building MythTv for Fedora is at: http://sourceforge.net/docman/display_doc.php?docid=24597&group_id=102048
Xine
A good DVD and other multi-media file player. Info on building this is at: http://sourceforge.net/docman/display_doc.php?docid=24184&group_id=102048
Mplayer
Another good multi-media file player.

Web Sites for Sources

Unichrome Graphics driver development
http://unichrome.sourceforge.net/
DRI Web site
http://sourceforge.net/projects/dri/