Jump to content

nVIDIA/TV-OUT

From Wikibooks, open books for an open world
NVIDIA

Introduction | TV-OUT | Twin View | SLI | Stereo


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

[edit | edit source]

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

[edit | edit source]

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
# Options ...
EndSection

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

[edit | edit source]

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

Value Country
"PAL-B" used in Australia, Austria, Belgium, Denmark, Estonia, Finland, Germany, Guinea, Hong Kong, Iceland, India, Indonesia, Italy, Malaysia, The Netherlands, New Zealand, Norway, Portugal, Singapore, Spain, Sweden, Switzerland and Russia
"PAL-D" used in China and North Korea
"PAL-G" used in Denmark, Finland, Germany, Iceland, Italy, Malaysia, The Netherlands, Norway, Portugal, Spain, Sweden and Switzerland
"PAL-H" used in Belgium
"PAL-I" used in Hong Kong, The United Kingdom, and most of the former colonies (i.e. South Africa, Australia, etc.)
"PAL-K1" used in Guinea
"PAL-M" used in Brazil
"PAL-N" used in France, Paraguay, and Uruguay
"PAL-NC" used in Argentina
"NTSC-J" used in Japan
"NTSC-M" used in Canada, Chile, Colombia, Costa Rica, Ecuador, Haiti, Honduras, Mexico, Panama, Peru, Puerto Rico, South Korea, Taiwan, United States of America, Venezuela, Dominican Republic...


Usage:

Option    "TVStandard" "NTSC-M"

TVOutFormat

[edit | edit source]

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

[edit | edit source]
Value Effect
"CRT" No effect, because you tell your videocard to use the monitor connected to the 15 pin VGA connector
"DFP" Everything will be printed on the flat panel connected to DVI/HDMI output
"TV" The monitor will be disabled and everything will be displayed on TV connected to the SVIDEO or COMPOSITE output
And in all combination for TwinView


Usage:

Option    "ConnectedMonitor" "CRT, TV"

A complete device-section

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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:

Effect
CTRL+ALT+F7 This is the original Xserver with your windomanager running. Your TV turns black.
CRTL+ALT+F8 This will be the tvout. You monitor turns black.


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

[edit | edit source]

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


Example Scripts to use the TV-Out

[edit | edit source]

Starting mplayer on TV

[edit | edit source]

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

#!/bin/sh
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

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


Parameter Explanation
exec replace shell with xinit and forward arguments
/usr/X11R6/bin/xinit xinit opens up a new X-Server and runs a command
/usr/bin/xterm -ut -e this is sometimes needed to get the right display
/usr/bin/mplayer the movie player
-stop-xscreensaver we don't want the screensaver active while watching a movie
-fs -vo sdl use fullscreen playback
"$@" forward parameters for mplayer
-- everything coming after this will be parameters for xinit and not mplayer
/usr/X11R6/bin/X this is the X-server we want to use
:1 the new screen will be located at ":1"
-layout tv we use our special ServerLayout "tv"


You can now play all your videos on TV:

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

</includeonly>

mplayerstart: Bash script with resume

[edit | edit source]

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.