NVIDIA/TV-OUT

Could you imagine a video-night sitting in front of a 17 '' monitor? Wouldn't it be much nicer to go through all your videos using a television? Most video cards don't provide direct SCART-connection to the TV, but some offer a S-Video connection.

This page provides step-by-step documentation on howto setup your X-Server and use Tv-out.

Setting up the X-Server
We need to edit three different parts of your X config file to make the X-server render your desktop or video to a television that is connected to your video card through the S-Video (or Composite) port on your videocard. They are used to associate a Monitor with a Device and define a Screen. If you look through your configfile you will notice that those sections already exist. No wonder, because we need one Device-, one Monitor- and one Screen- Section for each connected monitor/TV. In our case it's the original monitor (CRT) and the television. To make sure your monitor will work later on as well do not touch the existing sections. We will add new sections to support tv-out as well as the original monitor simultaneously. There is also a feature called TwinView which is not covered here.

Please make a backup of your configuration file before you make any changes to it.

Device-Section and its options
This section associates each installed videocard with a driver. As you look through the xorg.conf your device-section section should look like this right now:

Section "Device" Identifier "Videocard0"  # unique identifier for each video card Driver     "nvidia" VendorName "nVidia" BoardName  "nVidia Corporation NV15 [GeForce2 GTS/Pro]"  # see lspci EndSection
 * 1) Options ...

This Device Section controls the DVI/VGA output and ignores the tv-out and all devices connected to it. There are some special nvidia-options to use the tvout.

TVStandard
You should adjust this parameter to your monitor. In general you can take the value from this table:

Usage:

Option   "TVStandard" "NTSC-M"

TVOutFormat
This option is used to force the output to S-Video or Composite. If this option is missing it will be auto-detected. But be careful because this detection might fail. Possible values are SVIDEO and COMPOSITE.

Usage:

Option   "TVOutFormat" "COMPOSITE"

ConnectedMonitor
Usage:

Option   "ConnectedMonitor" "CRT, TV"

A complete device-section
Finally your new device section should look like this:

Section "Device" Identifier "Card_tv" Driver     "nvidia" BusID      "PCI:1:0:0"  # May differ (not needed unless you have two or more cards) Option     "TVOutFormat" "COMPOSITE"  # Or "SVIDEO" Option     "TVStandard" "NTSC-M" Option     "ConnectedMonitor" "TV" EndSection

The Monitor-section
As mentioned we need to setup a monitor device and define the Horizontal Syncronisation rate and the Vertical Refresh rate. You need not search for those numbers, because usually those numbers are the same for most televisions.

Section "Monitor" Identifier  "tv" HorizSync 30-50 VertRefresh 60 EndSection

The Screen-section
To complete the whole configuration we need to add a Screen section that associates the Device and Monitor sections and defines the desired display resolutions.

Section "Screen" Identifier "Screen_tv" Device    "Card_tv" Monitor   "tv" DefaultDepth 16 SubSection "Display" Depth    16 Modes "1280x1024" "1152x864" "1024x768" "800x600" EndSubSection EndSection

The ServerLayout-section
We now have two monitor-sections, two device-sections and two screen-sections. But how does X know what do with with them. Easy answer. There's another section defined with ServerLayout which can be used to switch the used devices. There should already exist a Section for that which controls your current monitor and defines what keyboard and mouse to use. Don't edit it unless you know what your doing. This Tutorial describes how to use several serverlayouts. So we add one more of them using our television Screen section:

Section "ServerLayout" Identifier    "tv" Screen        0  "Screen_tv" 0 0 InputDevice   "Mouse0" "CorePointer" InputDevice   "Keyboard0" "CoreKeyboard" EndSection

Permissions
On a Debian or Ubuntu system you will have to edit allowed_users in /etc/X11/Xwrapper.config to get permission to start the X server.

If xinit reports "user not authorized to run the X server, aborting", edit the file /etc/X11/Xwrapper.config as follows:

Change this line: allowed_users=console to allowed_users=anybody

Additionally, to connect to the server, you may need to launch X with "X :1 -layout tv -auth .Xauthority"

Finally
After putting all that into your configuration file we are ready to test the X-Server and write a little script to launch mplayer on the TV.

Testing Tv-Out
To test the TV out try this from and xterm on your CRT:

X :1 -layout tv

Your monitor should turn blank and might switch into Standby (SignalLost messages could also appear). If your TV is connected and the input selection is set correctly you should see the nVidia logo then the mousepointer should appear. To switch between monitor and TV you can use these key combinations:

''If those keys don't work, try to zap through all: start from F1 and go up to F12. One should be your windowmanager and another is the television. The others are terminal loginprompts.''

(In Ubuntu 7.04 the following has been found with the nvidia-glx driver on a Geforce4 Go 420 on issuing X :1 -layout tv:

(EE) NVIDIA(0): Unable to initialize the X Int10 module; the console may not (EE) NVIDIA(0): be restored correctly on your TV.

This been reported as a bug)

To open a terminal go to your windowmanager, open a prompt and type:

DISPLAY=:1 xterm

If you now switch back to your TV on F8 there will be a terminal popped up in the upper left corner of the screen. Your config passed the test. We can now try to handle all this in a useful way.

When trying the xterm command above, you may get an error similar to:

AUDIT: Tue May 17 14:57:14 2005: 18768 X: client 1 rejected from local host Xlib: connection to ":1.0" refused by server Xlib: No protocol specified

This error occurs if your system is using Xauthentication (xauth) to limit who can access a running X server. You need to tell X that you want to allow access from the local machine to display :1. The following command is one long command that is split across 2 lines. It will configure Xauthentication so that display :1 will accept connections from the same sources as display :0. This command was constructed on and it works on Mandriva 2005 LE, and has been seen to work on Fedora Core 5 and Ubuntu 6.06 (Dapper Drake). To configure Xauthentication for local access, open a prompt and type:

xauth add "$(/bin/hostname)/unix:1" MIT-MAGIC-COOKIE-1 \ $( xauth list | egrep "$(/bin/hostname)/unix:0" | awk '{print $3}' )

Shutting down the TV-SCREEN
It you want to shutdown the TV-screen session, you can easily use the same procedure as if you want to kill your X-Server.


 * 1) Activate the X-Session you want to terminate
 * 2) Press ALT + CTRL + BACKSPACE
 * 3) Switch back to your regular session and continue as if nothing happened

Starting mplayer on TV
To get a command for running mplayer on the TV, create a new file /usr/local/bin/mplayer.tv, with this content:

exec /usr/X11R6/bin/xinit /usr/bin/xterm -ut -e \ /usr/bin/mplayer -stop-xscreensaver -fs -vo sdl "$@" -- /usr/X11R6/bin/X :1 -layout tv
 * 1) !/bin/sh

Use locate or whereis to find the correct path if some commands are located elsewhere. ( FC5: /usr/bin/xinit and /usr/bin/X )

Make the script executeable:

chmod +x /usr/local/bin/mplayer.tv

You can now play all your videos on TV:

mplayer.tv /your/path/to/video.mpeg

mplayerstart: Bash script with resume
mplayerstart is a wrapper script for mplayer which allows the user to resume playback of a previously played file, supports several TV-out methods (including the xinit method above), disables screensavers, restores volume levels, and other features. The most recent version may be obtained here: mplayerstart.