Last updated: September 18, 2003
TV-out on the Matrox G450 (should work for the G550)
Synopsis:
-------------------
This page intends to help people get TV-out working on their Matrox
G450/G550 video cards
The TV-out patch was written by Petr Vandrovec (vandrove@vc.cvut.cz) and
released around Jun 8, 2002.
Petr Vandrovec is the matroxfb kernel driver maintainer.
People are encouraged to point out errors or discrepancies and feedback
is welcome (matrox_tvout@bglug.ca)
The newest version of this document can be found at http://www.bglug.ca/matrox_tvout/
I would also like to say that I am in no way affiliated with Matrox,
except that I own a G450 and have done my best to complain about a lack
of TV-out as witnessed in the forums ;)
Please note that the best way for Matrox to know about a demand for
TV-out under Linux is for you to email it's sales department. They
appear to be the only ones who can answer any questions regarding this
issue (although they have a tendency to not answer).
Thanks to the following people who have sent info/corrections/tips
(in order of date):
Hans Tool - Suggested a few things that should make things more
understandable
Maarten ter Huurne - Lots of PAL info. Some corrections and feedback on
some of my advice.
Pontus Edvardsson - Pointed out that the previous layout suggested that
v4lctl was only for adjusting the console settings, which isn't true.
Per Mattsson - Kernel build pointer.
Tim van Erven - Had lots of success with his G550. Pointed out many
things that I am looking into (ie: did not have the BusID problem).
Balázs Bárány - Pointed out the lack of directions
in regards to primary and secondary connectors.
Gemes Tibor - explained a better way to play videos with MPlayer (use
expand and scale together to preserve aspect ratio)
Frederic Lespez - reported success with 2.4.20 kernel.
Dave Smith - note on v4lctl
Pekka Tiittanen - a couple of notes on DirectFB
Balázs Bárány and Petri Koistinen - pointing out
just how outdated this doc was getting in regards to kernel versions,
sorry.
-------------------
1) Warning and limitations
I will warn you first that getting this to work may
require you (at this moment in time) to be proficient with linux and
compiling kernels.
This patch enables TV-out in PAL or NTSC. The resolution is currently
limited to no more then 640x480. The second head will only work in
16bit
or 32bit colour.
The first head (/dev/fb0) cannot be displayed using TVOut currently.
Petr Vandrovec has said this though
Maybe in future I'll add code to display 16/32bpp
resolutions up to 1023x625 from primary head on
TVOut too if you are
not using /dev/fb1 (by displaying same memory by
both CRTC engines),
but not now.
For those wanting to play movies on your TV- there is no acceleration
of any kind available. If you've watched movies in XFree86 using XV,
you
will notice that you can watch your movie at it's original size or in
fullscreen and it doesn't seem to slow down. This is done using the BES
(back-end-scaler) on the card. The BES resizes the video in hardware.
This unfortunately is not available on the second CRTC (only the
primary
CRTC). TV-out only works on the second CRTC, so no hardware resizing :(
XV also makes use of the colour-space conversion routines that again,
are not available on the second head.
Any movies you watch will have to be resized in software. Both mplayer
and xine are able to do this.
Also note that if you use a DVI flat panel, TV-out will not work
(unless you don't mind unplugging your DVI flat panel during POST, then
plugging it back in every boot).
This was posted by Petr Vandrovec <vandrove@vc.cvut.cz>
-----------
When G450/G550 BIOS finds that DVI monitor is attached, it somehow
programs something somewhere so that pixel PLL and video PLL values do
not work "as usual", but their behavior is somehow modified by setting
of DVI port.
It is not problem for normal monitor output on first head - when you
program pixelPLL and DVI output for same frequency, it behaves as it
should.
But if you want to use different pixel clock speed on secondary output,
there is a problem: you cannot. Your pixelclock must be in same DVI
frequency range, that is they can differ by aprox. +- 30%. If they
differ more, picture looses stability, and eventually disappears
(although video PLL still reports that it is locked and happilly
oscilating at frequency you requested...).
But with current multisync monitors this frequency limitation is
usually no problem, besides that you will usually use same picture size
on both heads, and so you also have same pixelclocks.
But when comes to TV out, you are lost: you must get exactly 50Hz (or
59.94) vertically and exactly 64us (63.975) line length. Even error by
1% is too big... This gives you 27MHz pixelclock, and this in turn
limits your primary head to <= 45MHz dotclock... So 800x600/60Hz is
your friend even on primary head :-( Problem, I think...
And worst is that if you'll boot without digital flat panel connected,
you can connect it later, and now you can have happily three
independent
outputs: analog 1, analog 2 (TV) and DVI which are driven by two
independent picture sources.
So if you do not want TVOut, or if you do not have DFP, there is no
problem. If you want DFP with TVOut, I'm sorry. You have to play with
cables during reboot.
---------
DirectFB
Some information about DirectFB. - The latest
version (0.9.16) includes TV-out support for the G400/G450/G550
included. DirectFB works in replace of the method I describe below. The
latest version of MPlayer includes a driver (dfbmga) that uses this
support to play wonderful looking video on the TV. It uses some of the
first heads features to improve the second heads quality. The downside
is that the first head is unusable while playing videos.
Unless you specifically need XFree86 support
(whether on the TV-out, or to be able to use X at the same time as
TV-out) then you should try the DirectFB method. Read Pekka Tiittanen's
HOWTO for instructions on how to use the DirectFB method.
The most recent official document can be obtained from here:
plain-text:
http://www.sci.fi/~syrjala/directfb/matrox-tv-out-howto
http://www.kauhajoki.fi/~peti/directfb/matrox-tv-out-howto
gzipped, plain text:
http://www.sci.fi/~syrjala/directfb/matrox-tv-out-howto.gz
http://www.kauhajoki.fi/~peti/directfb/matrox-tv-out-howto.gz
2) Needed Files
The original patch was made for the 2.5.20 version
of the kernel, but was back-ported to 2.4.19rc1. The patch is now
included in >=2.4.21 kernels so you are best to use one of these
kernels.
http://www.kernel.org/
- 2.4.19 is known to work with both the 2.4.19rc1
and 2.4.19rc5 versions of the mga-tvout patch
- 2.4.20 is known to work with the 2.4.19rc5 version
of the mga-tvout patch
- 2.4.21 and greater has support included
http://platan.vc.cvut.cz/ftp/pub/linux/matrox-latest/
- mga-tvout patch is available here if you wish to
use <2.4.21 kernel
- fbset-through-vt is available here if you wish to
use <2.4.21 kernel
- matroxset (0.3 is the latest at time of writing)
- con2fb.c.gz (if you want to have a console on your
TV)
Not essential, but the fbset program might be useful for changing your
fb settings (although fbset might be included in your distribution).
http://home.tvd.be/cr26864/Linux/fbdev/
- fbset
Some may want to adjust contrast and brightness settings. For this you
will need v4lctl (part of Xawtv, but compilable seperately).
Note that under debian, v4lctl is included with the xawtv package
(which requires XFree86 unfortunately).
http://bytesex.org/xawtv/index.html
-v4lctl
3) Patching the kernel
First you need to get a copy of the kernel source
(or grab a patch to apply to an existing source tree)
So visit your local http://www.kernel.org/
mirror, download and untar into /usr/src (first removing the
/usr/src/linux symlink, if
present).
# tar -xzvf
linux-2.4.19.tar.gz
Apply the patches. Skip the next five steps if using a kernel greater
then 2.4.20.
# gunzip
mga-2.4.19-rc5-tvout.gz
# gunzip
fbset-through-vt-2.4.19-rc5.gz
# cd /usr/src/linux-2.4.19
# patch -p1 -i
mga-2.4.19-rc5-tvout
# patch -p1 -i
fbset-through-tv-2.4.19-rc5
4) Compile your kernel
The 2.4.19-rc1 version requires you to enable
Multihead Support. This has been fixed in the 2.4.19-rc5 version. You
must compile it into the kernel as it will not currently work as a
module.
Matroxfb is a replacement for the VESA framebuffer. Your Matrox card
can use the VESA framebuffer, but when VESA fb initializes first, it is
no longer available to Matroxfb. Do not enable VESA fb support.
Here is what I have enabled on my system. If an option isn't listed, it
is disabled. Do not build any of the matrox stuff as modules with this
version of TV-out (if you're playing around with a newer version
though,
you can try it).
Not all these options are critical, but if you do not know what they
do, just select these.
These options are located in the "Console Drivers" section under
"Frame-buffer Support". If this submenu is not present, check that you
have enabled "Prompt for development and/or incomplete code/drivers"
(located under "Code maturity level options").
[*] Support for frame buffer devices
(EXPERIMENTAL)
<*> Matrox acceleration
(EXPERIMENTAL)
[*] G100/G200/G400/G450/G550
support
[*] Multihead support
<-- only needed with the
2.4.19rc1
version of the tv-out patch
[*] Advanced low level driver options
<*> 8 bpp packed
pixels support
<*> 16 bpp packed
pixels support
<*> 24 bpp packed
pixels support
<*> 32 bpp packed
pixels support
Compile your kernel...
# make dep && make
bzImage && make modules
# make install &&
make modules_install
I won't go into how to get the new kernel set up with lilo. After
the kernel is in place, you must set a FB video mode. You can catch
LILO
and add "video=matrox:vesa:0x111" to the boot prompt. Mode 0x111 is for
640x480 at 16bit colour and mode 0x112 is 640x480 at 32bit colour. I
believe that 640x480 is the largest resolution that is supported. Once
you get things working, you can make lilo append this for you. Here is
a
sample entry from my /etc/lilo.conf file.
image = /boot/vmlinuz-2.4.19
label = linux-tvout
append = " ide1=autotune ide0=autotune video=matrox:vesa:0x111"
root = /dev/hda2
read-only # use read-write if you use reiserfs, don't
know about other filesystems
Just be sure to run lilo after making the change.
5) Activate TV-out
Before we proceed, it is important to make sure that
the TV-out cable is hooked-up correctly. The TV-out adaptor must be
connected to the secondary output.
There are two kinds of outputs, HD-15 (which is an ordinary analog
monitor output) and DVI.
If your card has two HD-15 connectors, then you will need to look
closely for a "1" ( or "1/3" ) and "2"( or "2/4" ) stenciled beside
each
connector. Plug the TV-out adaptor to the second one ("2" or "2/4").
If you have a HD-15 and a DVI connector, then you will need to plug
the TV-out adaptor to the HD-15 connector (regular video port). In this
case, your DVI output is your primary output.
Now to actually activate it.
Your video card is capable of a few different configurations, so the
command line tool "matroxset" was created to be able to change those
settings.
Building matroxset is fairly simple.
# tar
-xzvf matroxset-0.3.tar.gz
# cd
matroxset
# make
[root]# cp matroxset /usr/sbin
The matroxset tool doesn't have to be run as root, as long as the
current user has read/write access to the framebuffer devices.
Once you have found what settings you use, you may also want to add
them to your startup scripts
# matroxset -f /dev/fb0 -m 5
This turns secondary output off
# matroxset -f /dev/fb1 -m 2
Connect secondary output to
/dev/fb1
# matroxset -f /dev/fb1 -o 1 2
Set output 1 (secondary output)
to NTSC.
# matroxset -f /dev/fb1 -o 1 1
Set output 1 (secondary output)
to PAL.
At this point, TV-out should be working, but it may look like it
isn't (snowy or odd pattern). You should now be able to use /dev/fb1.
Now would be a good time to test it. If you have a program that
supports
output to a framebuffer device, try it (but be sure to send it's output
to /dev/fb1).
# mplayer -vo fbdev -fb /dev/fb1 myfile.mpg
"-vop scale" tells mplayer to resize in software, so it might make
it choppy. Using the expand/scale options together will scale the video
to fill the screen, while preserving the aspect ratio. The "expand"
option tells mplayer how big of a screen to use (putting a black border
around the extra area) and "scale" will scale the video to fill the
area
specified. One could just leave the scale option out to have the video
displayed centered while in it's original size.
I had some "tearing" issues when playing complex videos (mostly DVDs)
that I was able to make look alot better by using "-ssf lgb=1". This
applies a gaussian blur to the luma data. It looks better, but who
really wants to be bluring their videos?
# mplayer -vo fbdev -fb /dev/fb1 -vop
expand=640:480,scale=640:-2 somefile.mpeg
TV-out (fb1) should be set by default to 640x480x32. To change it
use fbset, but I don't recommend changing it unless you have a specific
need.
# fbset -fb /dev/fb1 -xres 400 -yres 260
-depth 16 <-- just an example
Recommended resolution for PAL is
# fbset -yres 576 -xres 768 -upper 44 -lower 4
-vslen 1
You can set -xres to (512 <= xres < 1024).
6) Adjusting the picture
Petr Vandrovec says that he has got a few people asking about making
the screen brighter, but I haven't needed to adjust my settings.
v4lctl can be used to make these adjustments. v4lctl is part of xawtv
and fbtv. Please notice that I am specifying fb0 with v4lctl.
# v4lctl -c /dev/fb0 bright XXX
Set brightness 0-1023
# v4lctl -c /dev/fb0 contrast XXX
Set contrast ...
See v4lctl -c /dev/fb0 list for
list of option
The following is from Maarten ter Huurne on his experience with
brightness/contrast
------------------------------------------------
I had a serious
brightness/contrast problem; the output looked very bad.
Strange that you didn't experience it, maybe this problem only occurs
with
PAL? (assuming Canada uses NTSC)
Anyway, I tried various brightness/contrast settings and they all looked
awful, until I set contrast to 0. On my setup, there is a very
discontinuous
change at contrast 185: 185 shows high contrast, 186 shows a black
screen.
The entire range 0..185 has a lot more contrast than any value in the
range
186..1023. I cannot explain it.
------------------------------------------------
Canada and the US do use NTSC. It appears the brightness/contrast
problem is a PAL issue (possibly).
Here is a follow-up from Maarten ter Huurne
------------------------------------------------
I applied the 2.4.19-rc5 patch on the 2.4.19 release kernel (which is
the same
as 2.4.19-rc5) and that fixed the strangeness on the brightness/contrast
controls. Now 0 is lowest just as one would expect. The settings I
currently
use are "bright 320", "contrast 280", "color 76" and "hue 0".
------------------------------------------------
7) Getting a console
Uncompress con2fb
# gunzip con2fb.c.gz
Then compile and install
# gcc -Wall -o con2fb con2fb.c
# mv con2fb /usr/sbin
Now to set a console on fb1. Change tty5 to whichever console you
want to be connected to fb1.
# con2fb /dev/fb1 /dev/tty5
Now hit alt-f5 and you should see picture on the TV.
8) Getting XFree86 to play nicely (recently revised, may need corrections)
Now we need to add some options to the
/etc/X11/XF86Config-4 file. This will vary depending on what you want
your setup to do. If you have a G450 (the G550 doesn't appear to have
this problem), then you will have to contend with the BusID problem.
This problem comes into play when the first head uses the mga driver, but the second
needs
the fbdev driver. The
second driver fails to initialize because the first head (mga driver) has already claimed
that BusID. The solutions available are:
a) Not use X on the second head, just use it as a FB (you can play
movies with a console and direct the output to the fb1 device, this is
what I do)
Only the two options marked below need to
be added to get XFree86 to cooperate. This setup doesn't allow XFree86
any control of the second head. You can simply use a terminal (xterm,
aterm, etc...) to launch any fb programs. Just make sure that you tell
the program to use the fb1 device.
Section
"Device"
Identifier "MATROX CARD 1"
Driver "mga"
VendorName "Matrox"
BoardName "G450"
BusID "PCI:1:0:0"
Option "UseFBDev"
<--
Add this option, otherwise the screen will be corrupted
Option "HWcursor" "no" <--
Make sure to add this to prevent a corrupted cursor
EndSection
b) Use the same driver for both heads. This means that any features
(DRI, XVideo, etc...) will not be available. If you use Xinerama, the
colour depth must be the same for both heads.
Look for a Device section (there could be
several, but there needs to be one for each head that you want to use).
This section is from my config for the first head.
Section
"Device"
Identifier "MATROX CARD 1"
Driver
"fbdev" <-- fewer features, but won't
conflict with second head
VendorName
"Matrox" note that G550 users can try the mga
driver instead
BoardName "G450"
BusID "PCI:1:0:0"
<-- This number will vary, but
AGP
cards will use this number
Option "UseFBDev"
<-- Add this option, otherwise
the
screen will be corrupted
Option "HWcursor" "no" <-- Make sure to add this to prevent
a corrupted cursor
Option "fbdev"
"/dev/fb0"
EndSection
The second head will need something
similar to the following.
Section
"Device"
Identifier "MATROX CARD 2"
Driver "fbdev"
VendorName "Matrox"
BoardName "G450"
Option "fbdev" "/dev/fb1"
EndSection
The second head needs a Monitor and
Screen section.
Section "Monitor"
Identifier "console"
VendorName "Unknown"
ModelName "Unknown"
HorizSync 31.5 - 31.5 <-- Make certain that if a monitor
is hooked-up
VertRefresh 50.0 - 70.0 to this head that these settings are ok
EndSection
Section "Screen"
Identifier "Display 2"
Device "MATROX CARD 2"
Monitor "console"
DefaultDepth 16 <-- change to match your fb settings
SubSection "Display"
Depth
16 <-- change
to match your fb settings
Modes "640x480" <-- change
to match your fb settings
EndSubSection
EndSection
Next you will need to modify the ServerLayout section to add another
screen.
Section
"ServerLayout"
Identifier "tvout"
Screen "Display 1" 0 0
Screen "Display 2" RightOf
"Display 1"
InputDevice "Mouse1" "CorePointer"
InputDevice "Keyboard1" "CoreKeyboard"
EndSection
9) Conclusion/getting help
Notice about using fbtv. I have noticed that fbtv seems to require it's
own console. Therefore you must setup a console on fb1 using con2fb and
then run fbtv from that console.
Here are a few links that may be useful
- Teletux Digital Video
- SyncFB module. This module is better for viewing movies on your
monitor.
- Macro disable
- Perl script to disable Macrovision copy protection
- MPlayer
Docs - section on TV-out
- DirectFB
- using DirectFB to provide features similar to windows DVDMax.
Check the link below, check my
tvout main page for updates, or email me at matrox_tvout@bglug.ca
Good-luck!
Dan Eriksen