Via Unichrome TV Output HowTo

Terry Barnaby - BEAM Ltd

6/5/05

Introduction

This page provides some basic information on getting the Unichrome driver to display on a TV in a quality manner for viwing DVD and DVB-T TV video streams. It is based on my limited experience of trying to improve the quality of the TV output, using MythTv, on my Via M10K box.
Note that due to heavy development this could well be out of date by the time you read it.

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 M10K platform includes a Via CLE266 chip which provides, amongst other things, a dual channel VGA graphics controller. One of the VGA controllers outputs is connected to the M10K's 15pin VGA connector and the other is sent through a TV chip which generates the TV output signals.

You can connect a TV to a M10K in one of the ways listed below:

Composite
The TVComposite connector provides a normal TV quality composite signal. On the Via M10K there is a jumper to switch this output to be a digital audio feed instead. I uses this connector for digital audio out to my surround sound amplifier.
SVideo
The S-Video connector provides a higher quality Y + C signal. This is the connection I use to my TV.
TV RGB
On some boards (not the M10K) the RGB outputs from the TV chip are provided.
YPbPr On some boards (not the M10K) component outputs from the TV chip are provided.


VGA RGB
It is possible, with a suitable VGA to SCART lead and a simple SYNC circuit to connect the RGB inputs of a TV to the VGA RGB outputs. The current Unichrome driver does not support the mode settings for this yet. It may not be able to if it does not support interlaced operation.

Current Status

Testing TV Output Quality

I have generated a simple MPEG test video for testing the quality of TV output. There is information on this on the following line:

Basic Setup For TV Output

On startup the Unichrome driver can sense the connection of a VGA monitor and TV. If a TV is connected it will limit the graphics modes to those supported by the TV output chip. If a monitor is connected the VGA controllers primary CRTC controller will be used for this. Its scan rate can be set as required for the monitor but the modes will be limited to those that the TV Output chip can handle. The TV output chip will use the VGA's secondary CRTC controller if a VGA monitor is connected or the primary one if only the TV is connected. The scan rates for this CRTC controller will be set up to match the TV output ie either 50Hz or 60Hz for PAL or NTSC as appropriate.
The actual monitor settings for the ModeLines in /etc/X11/xorg.conf are ignored for the TVOutput system, however you still need to have a mode line there for the x/y resolutions you require. I believe this is used by the higher level portions of the Via driver to determine what modes are available and to perhaps check memory bandwidth usage.
The TVComposite and TVSVideo outputs will be driven. The graphic modes supported currently depends on the TV type used. For both PAL and NTSC 1024x768, 800x600 and 640x480 are available.
For PAL TV's the native resolution of 720x576 is available and this is the preferred resolution to use.
For NTSC TV's the native resolution of 720x480 is available and this is the preferred resolution to use.

The vertical sync interrupt is driven from the primary display CRTC. This means that if a monitor and TV are plugged in then it will be driven at the vertical sync rate of the monitor (60Hz, 70Hz ...). If just a TV is plugged in then as this uses the primary CRTC the vertical sync interrupt will be at 50Hz in sync with the TV's odd/even displayed fields. Some MPEG2 players, including MythTv, synchronise their frame outputs to the vertical sync interrupt. It is much better to have the MPEG2 player synchronising itself to the TV's sync as this reduces motion "juddering" due to interlaved fields being displayed out of order. So for high quality TV output, remove that monitor ! (We could add a driver switch to change the vertical interrupt source ....)

Some useful settings in /etc/X11/xorg.conf include:

Option
Possible Values
Description
ActiveDevice
"CRT","TV","CRT,TV"
Set the output devices in use
TVType
PAL,NTSC
Type of TV connected. Changes TV output signal format
TVOutput
Composite, S-Video,RGB
Changes the TV output connection in use
TVDeflicker 0,1,2
Enables the TV Outputs de-flicker filter 0 is off, 1 and 2 are on settings.



DisplaySize 400 300
In the monitor section set the display size to be a 4:3 ratio for 4:3 TV's
DisplaySize
400 225
In the monitor section set the display size to be a 16:9 ratio for 16:9 TV's

More information is given in the Unichrome's "via.4.html" manual page. This is present in the source directory for the Via driver.

Note that you can set the DisplaySize option within the configuration files "Monitor" section to be a "16:9" ratio if you have a "16:9" TV or a "4:3" TV with a "16:9" mode. If you do this some applications, including MytTv and Xine, will scale the Video display correctly. Note that if you set this to the actual screen size, some applications, notably MythTv, will scale the fonts so that the point size is correct. Unfortunately this leeds to very small fonts on large screen TV's !!

Although the TV Output chip can be set to different modes, such as 1024x768, the display quality will always be much better if you use the native display resolution of the TV. A TV is a fixed resolution display device. A PAL TV has a basic resolution of 720x576 and an NTSC one 720x480. Although PAL is 625 lines some of these are effectively offscreen. The horizontal resolution is actually limited by the conection type (Composite, SVideo, RGB) and the frequency response of the analogue circuits in the TV.
If you use any other resolution the TV Output chip will scale down and filter the image, reducing display quality and messing up the interlaced fields. Messing up the interlaced fields causes nasty artifacts when motion is present in a video.
Note also that even the 576 lines are interlaced. So that only 288 lines are output every 50Hz. In a picture type image this is Ok, but if you want to output computer graphics which may just use 1 pixel wide lines, this leads to a lot of display flicker. A TV is a poor relation of a computer monitor ! The VT1622 does have a de-flicker filter to reduce this. However if enabled it will reduce the quality of video pictures due to the filtering and interlace mess up caused.

The basic rule, for display quality, no scaling or filtering is good !

In my case I have a 4:3 TV driven through the SVideo input. I run the display using the mode "720x576Noscale" to match the DVD's and DVB digital TV input signal so that no scaling should be needed when viewing 4:3 source. I have added a "fill" aspect override mode to MythTv. This is in the CVS version of MythTv (1/3/2005). When viewing 16:9 or 4:3 source I use MythTv's "fill" aspect ratio function to scale the output to my TV. This aspect ratio setting will keep the vertical unscaled and clip/scale the horizontal to fit on the TV.

For a 16:9 TV I would set as above but set the DisplaySize, in xorg.conf, to "400 225"....

Here is my xorg.conf file.

For a 4:3 PAL TV I would setup the following (use 720x480 for NTSC):
  1. Use the CVS Via driver (After 1/3/05) which have my NoScale patch included. Or use my Fedora drivers at: http://www.kingcot.eclipse.co.uk/unichrome/ which have this patch included. This turns off TVoutput video scaling when in "720x576Noscale" mode.
  2. Set the display mode to "720x576Noscale". See or use my xorg.conf file. This matches DVB Digital TV and PAL DVD's so no scaling should be needed to display the data. PAL TV's can just about display this image with only minor overscan.
  3. Set the "DisplaySize" option in the monitor section of /etc/X11/xorg.conf to "400 300", a 4:3 size. This should get xine to not do any scaling for 16:9 videos assuming xine honors the screen aspect ratio, MythTv does.
  4. Set MythTv or xine to zoom the image to fit the vertical size but clip the horizontal. The "fill" Aspect mode setting will do this.
  5. Set MythTv to de-interlace using "Bob and Weave".
  6. Make sure that just a TV, no monitors are plugged in (Vertical sync to TV). It will work with a monitor plugger in, but there may be motion jitter.
For a 4:3 PAL TV with a 16:9 mode I would setup the following (use 720x480 for NTSC):
  1. Use the CVS Via driver (After 1/3/05) which have my NoScale patch included. Or use my Fedora drivers at: http://www.kingcot.eclipse.co.uk/unichrome/ which have this patch included. This turns off TVoutput video scaling when in "720x576Noscale" mode.
  2. Set the display mode to "720x576Noscale". See or use my xorg.conf file. This matches DVB Digital TV and PAL DVD's so no scaling should be needed to display the data. PAL TV's can just about display this image with only minor overscan.
  3. Set the "DisplaySize" option in the monitor section of /etc/X11/xorg.conf to "400 225", a 16:9 size. This should get xine to not do any scaling for 16:9 videos assuming xine honors the screen aspect ratio, MythTv does.
  4. Set the TV to 16:9 mode.
  5. Set MythTv or xine to zoom the image to fit the vertical size but clip the horizontal. The "fill" Aspect mode setting will do this.
  6. Set MythTv to de-interlace using "Bob and Weave".
  7. Make sure that just a TV, no monitors are plugged in (Vertical sync to TV). It will work with a monitor plugger in, but there may be motion jitter.
For a 16:9 PAL TV I would setup the following (use 720x480 for NTSC):
  1. Use the CVS Via driver (After 1/3/05) which have my NoScale patch included. Or use my Fedora drivers at: http://www.kingcot.eclipse.co.uk/unichrome/ which have this patch included. This turns off TVoutput video scaling when in "720x576Noscale" mode.
  2. Set the display mode to "720x576Noscale". See or use my xorg.conf file. This matches DVB Digital TV and PAL DVD's so no scaling should be needed to display the data. PAL TV's can just about display this image with only minor overscan.
  3. Set the "DisplaySize" option in the monitor section of /etc/X11/xorg.conf to "400 225", a 16:9 size. This should get xine to not do any scaling for 16:9 videos assuming xine honors the screen aspect ratio, MythTv does.
  4. Set MythTv or xine to zoom the image to fit the vertical size but clip the horizontal. The "fill" Aspect mode setting will do this.
  5. Set MythTv to de-interlace using "Bob and Weave".
  6. Make sure that just a TV, no monitors are plugged in (Vertical sync to TV). It will work with a monitor plugger in, but there may be motion jitter.

Xine

I have not done much work with Xine output on TV's, but here are a few pointers:
The following Xine options need to be set in ~/.xine/config:
    video.driver:xxmc   
    video.device.xvmc_bob_deinterlacing:1
    gui.deinterlace_by_default:1
If your incoming video's aspect ratio does not match your display, you can try adding the following:
    video.output.disable_scaling:1
This will eliminate scaling and hence scaling and interlace artifacts but will mess up the aspect ratio. Xine does not have an effective "fill" aspect ratio mode as far as I am aware that would allow 16:9 video to be zoomed and croped (left and right) to fill a 4:3 TV.

Basic Operation using TV Output Chip

I have a utility program, vt1622.c,  that I have used to modify the VT166 TV chips settings live. This is available here or on the Unichrome sourceforges CVS site.

Web Sites for Sources

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