X, Video Drivers, & Monitors

Commands

Use xdpyinfo to display information about an X server. See man page for details.

Use xwininfo to display information about a specific X window. Select the window of interest with the mouse after starting the command. Retrieved information includes the window's dimensions and coordinates. See man page for details.

Use xvinfo to display a video adapter's capabilities.

Use xdriinfo to get information about the DRI (Direct Rendering Interface) driver behind an X screen. With an Intel video card, for example:

-> xdriinfo 
Screen 0: i915

Or, with a Radeon 9250 card:

-> xdriinfo 
Screen 0: r200

xrandr Basics

Use xrandr to query the configurations of X's screen and monitors; to configure the resolution, rotation, and reflection for a monitor; and to setup two monitors attached to a dual-head video card. Run xrandr as an ordinary user; it does not require root privileges.

These notes use version 1.3.4:

-> xrandr --version
xrandr program version       1.3.4
Server reports RandR version 1.3

Conceptually, xrandr works in terms of screens and outputs. X by and large renders graphics into a rectangular screen, or frame buffer, residing in the graphics card's memory. This abstract screen is what the user wants to see in whole or in part. The graphics card and its driver then have the job of getting the screen displayed on one or more attached monitors. An output is pretty-much a monitor connected to the video card via a specific adapter (i.e. VGA, DVI, LVDS, S-Video). But when an adapter lacks an attached monitor, an output reduces to the adapter itself. More technically, it may be instructive at times to think of the output as the pipeline uniting frame buffer, CRTC, adapter, and monitor (if present).

Typically, a video card has a single adapter with a single monitor attached, and X's screen takes on the dimensions of the monitor's preferred resolution. There is a one-to-one correspondence between screen pixels and monitor pixels. If the video-card has a second adapter that is not connected to a monitor, the extra output is duly noted but subsequently ignored. Here are two examples.

Example 1: Here's an example from a desktop computer that has an Intel graphics card with a VGA adapter only.

-> xrandr --query
Screen 0: minimum 320 x 200, current 1440 x 900, maximum 2048 x 2048
VGA1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 408mm x 255mm
   1440x900       59.9*+   75.0  
  1280x1024      75.0     60.0  
   ...

xrandr reports a single screen, labeled "0", with current dimensions 1440×900. It also shows the minimum and maximum permitted screen dimensions, which are determined by the video card. The screen is connected to a single output, a VGA monitor labeled "VGA1." The monitor's resolution is 1440×900 and its viewable area is about 16in×10in (408mm×255mm). Next, xrandr reports additional modes that the monitor offers; for brevity, only two are reproduced here. It marks the monitor's preferred and current modes with a plus sign ("+") and an asterisk ("*"), respectively. (Think "p" for plus and "p" for preferred; "a" for asterisk and "a" for active.) In this simple setup, there is a one-to-one correspondence between screen pixels and monitor pixels, but such a correspondence is not required.

Example 2: This netbook has a built-in monitor and an unplugged connector for a VGA monitor.

-> xrandr
Screen 0: minimum 320 x 200, current 1024 x 600, maximum 4096 x 4096
LVDS1 connected 1024x600+0+0 (normal left inverted right x axis y axis) 223mm x 125mm
   1024x600       60.0*+   60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)

Output "LVDS1" denotes the built-in monitor, and "VGA1" denotes the external adapter.

In general, a monitor displays a rectangular region of X's screen. The screen itself is agnostic with regard to the number of monitors looking on. These regions are variously called "zones" and "viewports." xrandr provides the means to easily map a monitor onto a viewport. Two monitors on a dual-head video card can display the same zone, partially overlapping zones, or disjoints zones. With panning, a monitor's underlying viewport can even scroll over X's screen in response to mouse movements.

Example 3: This desktop has an ATI Radeon video card with three adapters: one VGA, one DVI, and one S-Video (TV). A VGA monitor and a DVI monitor are plugged in. The S-Video connection is empty.

-> xrandr --query
Screen 0: minimum 320 x 200, current 2720 x 1024, maximum 4096 x 4096
VGA-1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 408mm x 255mm
   1440x900       59.9*+   75.0  
   1280x1024      75.0     60.0  
   ...
DVI-0 connected 1280x1024+1440+0 (normal left inverted right x axis y axis) 338mm x 270mm
   1280x1024      60.0*+
   1152x864       75.0  
   ...
S-video disconnected (normal left inverted right x axis y axis)

X's screen has dimensions 2720×1024. The two monitors use their preferred resolutions. The VGA monitor, output VGA-1, displays the 1440×900 rectangle coinciding with the screen's upper-left corner ("+0+0"). The DVI monitor, output DVI-0, displays the 1280×1024 sub-region to the immediate right ("+1440+0"). The screen's horizontal dimension is the sum of the two monitors' horizontal dimensions (2720=1440+1280), and the screen's vertical dimension is the maximum of the two monitors' vertical dimensions (1024=max[900,1024]). The screen has a 1440×124 occult rectangle at its bottom-left corner (124=1024-900). The three disjoint rectangles cover the entire screen.

The video-card driver (or possibly the card itself) determines the names of outputs. Radeon uses "VGA-1," "DVI-0," "LVDS", and "S-video." Intel uses "VGA1," "DVI1," and "LVDS1". Both "LVDS" and "LVDS1" refer to a laptop's built-in display. "S-Video" is a TV output. Output names are case-sensitive in xrandr commands.

When tinkering with configurations, use options --verbose and --dryrun together to get an idea of what xrandr will do. For example:

-> xrandr --output DVI-0 --same-as VGA-1 --verbose --dryrun
crtc 1: disable
screen 0: 1440x1024 379x270 mm  96.33dpi
crtc 1:    1280x1024   60.0 +0+0 "DVI-0"

xrandr with Dual Monitors

Cloning Outputs

Use option --same-as to clone two congruent monitors:

TDB

Horizontal Viewports

Use options --left-of and --right-of to place two viewports side-by-side. Here's the xrandr command that arranged the two monitors of Example 3, above, wherein the VGA and DVI monitors sit in left-right order:

-> xrandr --output DVI-0 --right-of VGA-1

Equivalently:

-> xrandr --output VGA-1 --left-of DVI-0

The tops of the two monitors' viewports both lie along the top of X's screen. The left edge of the VGA-1 viewport lies along the left edge of the screen, and the right edge of the DVI-0 viewport lies along the right edge of the screen. The right edge of VGA-1 and the left edge of DVI-0 abut each other. The VGA-1 zone has dimensions 1440×900; the DVI-0 zone is 1280×1024. In terms of the screen's coordinates, the VGA-1 viewport has its upper-left corner, or anchor herein, at (0,0). The DVI-0 viewport is anchored (1440,0). The screen's hidden rectangle is anchored at (0,900).

Alternatively, use option --pos to explicitly set the viewports' anchors. Here's a third way to arrange the VGA and DVI outputs in left-right order:

-> xrandr --output VGA-1 --pos 0x0 --output DVI-0 --pos 1440x0 

Finally, here are three equivalent ways to swap the horizontal placement in Example 3, so that the DVI monitor instead lies to the left of the VGA monitor:

-> xrandr --output DVI-0 --left-of  VGA-1
-> xrandr --output VGA-1 --right-of DVI-0
-> xrandr --output DVI-0 --pos 0x0 --output VGA-1 --pos 1280x0

Now the occult region of the screen has its upper left corner at (1280,900).

See also: ThinkWiki. X.Org wiki. Ubuntu wiki. Intel notes.Gentoo Wiki.

Vertical Viewports

You can arrange viewports vertically with switches --above and --below for relative placement or with switch --pos for absolute placement. The screen's size automatically adjusts to accommodate stacking. Its width becomes the maximum of the two viewports' widths, and its height becomes the sum of the viewports' heights. Here's how to stack the outputs for the system in Example 3.

To put VGA-1 on top:

-> xrandr --output DVI-0 --below VGA-1
-> xrandr 
Screen 0: minimum 320 x 200, current 1440 x 1924, maximum 4096 x 4096
VGA-1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 408mm x 255mm
...
DVI-0 connected 1280x1024+0+900 (normal left inverted right x axis y axis) 338mm x 270mm
...

In the screen's dimensions, 1440=max[1440,1280] and 1924=900+1024. VGA-1 anchors at (0,0), and DVI-0 anchors at (0,900).

To instead put DVI-0 on top:

-> xrandr --output DVI-0 --above VGA-1
-> xrandr 
Screen 0: minimum 320 x 200, current 1440 x 1924, maximum 4096 x 4096
VGA-1 connected 1440x900+0+1024 (normal left inverted right x axis y axis) 408mm x 255mm
...
DVI-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
...

The screen's dimensions remain the same as above. But DVI-0 anchors at (0,0), while VGA-1 slides down to (0,1024).

For the record, the following commands use absolute placement rather than the relative placement just demonstrated. The first puts VGA-1 on top, the second puts DVI-0 on top.

-> xrandr --output VGA-1 --pos 0x0    --output DVI-0 --pos 0x900 # VGA-1 above DVI-0
-> xrandr --output VGA-1 --pos 0x1024 --output DVI-0 --pos 0x0   # VGA-1 below DVI-0

Disable and Enable Output

Use switch --off to disable an output altogether. The screen automatically assumes the dimensions of the remaining output.

To disable DVI-0, for example:

-> xrandr --output DVI-0 --off
-> xrandr
Screen 0: minimum 320 x 200, current 1440 x 900, maximum 4096 x 4096
VGA-1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 408mm x 255mm
...
DVI-0 connected (normal left inverted right x axis y axis)
   1280x1024      60.0 +
...

To later enable the output, use switch --auto:

-> xrandr --output DVI-0 --auto
-> xrandr
Screen 0: minimum 320 x 200, current 1440 x 1024, maximum 4096 x 4096
VGA-1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 408mm x 255mm
...
DVI-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
...

In the absence of additional direction, as here, the screen's width becomes the maximum of the two outputs' widths (1440), and its height becomes the maximum of the two outputs' heights (1024). Both viewports anchor at position (0,0) in the screen, so that the two monitors mirror each other over the intersection of their viewports.

Netbook Panning

You can use the --panning switch to make your netbook's (or laptop's) built-in monitor pan over the larger display of an external monitor. As the mouse approaches the edges of the internal monitor, the viewport of the built-in monitor moves to track the larger viewport of the external monitor. The built-in monitor thus appears to scroll horizontally or vertically to reveal a larger screen.

Here is the initial state of a netbook booted with a monitor attached to the external VGA port. By default, the screen has two independent viewports aligned side-by-side. The output LVDS1 shows the left viewport on the built-in monitor, and output VGA1 shows the right viewport on the external monitor.

-> xrandr 
Screen 0: minimum 320 x 200, current 2304 x 1024, maximum 4096 x 4096
LVDS1 connected 1024x600+0+0 (normal left inverted right x axis y axis) 223mm x 125mm
   1024x600       60.0*+   60.0  
   ...
VGA1 connected 1280x1024+1024+0 (normal left inverted right x axis y axis) 338mm x 270mm
   1280x1024      60.0*+   75.0  
   ...

To have the netbook's 1024×600 monitor pan over the display, use this command:

-> xrandr --fb 1280x1024 --output LVDS1 --panning 1280x1024 --output VGA1 --pos 0x0 --verbose
screen 0: 1280x1024 332x266 mm  97.69dpi
crtc 0:    1280x1024   60.0 +0+0 "VGA1"
crtc 1:     1024x600   60.0 +0+0 "LVDS1"
-> xrandr
Screen 0: minimum 320 x 200, current 1280 x 1024, maximum 4096 x 4096
LVDS1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 223mm x 125mm panning 1280x1024+0+0
   1024x600       60.0*+   60.0  
   ...
VGA1 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
   1280x1024      60.0*+   75.0  
   ...

When you disconnect the external VGA monitor, you'll need to reset the built-in LVDS display:

-> xrandr --output LVDS1 --auto --panning 0x0 --output VGA1 --off --verbose
crtc 0: disable
screen 0: 1024x600 269x157 mm  96.69dpi
crtc 1:     1024x600   60.0 +0+0 "LVDS1"
-> xrandr
Screen 0: minimum 320 x 200, current 1024 x 600, maximum 4096 x 4096
LVDS1 connected 1024x600+0+0 (normal left inverted right x axis y axis) 223mm x 125mm
   1024x600       60.0*+   60.0  
   ...
VGA1 disconnected (normal left inverted right x axis y axis)

Xorg.0.log

X logs messages to /var/log/Xorg.0.log. Browse this log to debug or just invesitigate X.

Check out the video drivers loaded:

-> grep driver /var/log/Xorg.0.log | grep Loading
[    38.825] (II) Loading /usr/lib/xorg/modules/drivers/ati_drv.so
[    38.826] (II) Loading /usr/lib/xorg/modules/drivers/radeon_drv.so
[    38.828] (II) Loading /usr/lib/xorg/modules/drivers/vesa_drv.so
[    38.829] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[    38.877] (II) Loading /usr/lib/xorg/modules/drivers/radeon_drv.so

Review the outputs probed:

-> grep Output /var/log/Xorg.0.log
[    39.065] (II) RADEON(0): Output VGA-1 has no monitor section
[    39.190] (II) RADEON(0): Output DVI-0 has no monitor section
[    39.190] (II) RADEON(0): Output S-video has no monitor section
[    39.436] (II) RADEON(0): Output VGA-1 connected
[    39.436] (II) RADEON(0): Output DVI-0 connected
[    39.436] (II) RADEON(0): Output S-video disconnected
[    39.436] (II) RADEON(0): Output VGA-1 using initial mode 1440x900 +0+0
[    39.436] (II) RADEON(0): Output DVI-0 using initial mode 1280x1024 +1440+0

Monitors

A graphics card can read an attached monitor's EDID (Extended Display Identification Data) to learn the monitors' capabilities. X uses this information in dynamically configuring itself.

Use monitor-edid (from package monitor-edid) to display a monitor's EDID information:

-> monitor-edid 
Name: L1732TQ 
EISA ID: GSM43f9
EDID version: 1.3
EDID extension blocks: 0
Screen size: 33.8 cm x 27.0 cm (17.03 inches, aspect ratio 5/4 = 1.25)
Gamma: 2.2
Digital signal
Max video bandwidth: 110 MHz
	HorizSync 30-71
	VertRefresh 56-75
	# Monitor preferred modeline (60.0 Hz vsync, 64.0 kHz hsync, ratio 5/4, 96 dpi)
	ModeLine "1280x1024" 108 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync

There is no man page. Use option -v to list modes supported in addition to the preferred mode. Use option --perl for some more details (as a Perl hash). Try --help also.

Models and Specifications

Video Cards & Drivers

See what's in the box:

-> lspci | grep -P "AGP|PCI Express|VGA|Display"
00:02.0 Display controller: Intel Corporation 82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device (rev 01)
01:05.0 VGA compatible controller: ATI Technologies Inc RV280 [Radeon 9200 PRO] (rev 01)
01:05.1 Display controller: ATI Technologies Inc RV280 [Radeon 9200 PRO] (Secondary) (rev 01)

General: Gentoo Wiki. KMS.

ATI Radeon: man ati. man radeon. man 128. X.Org Wiki. Gentoo Wiki.

Intel: Intel Linux Graphics. Gentoo Wiki. X.org IntelGraphicsDriver.

CRTC: Debian.

VGA-1 connected 1440x900+0+0 (0x54) normal (normal left inverted right x axis y axis) 408mm x 255mm
	Clones:     DVI-0
	CRTC:       0
	CRTCs:      0 1
DVI-0 connected 1280x1024+1440+0 (0x56) normal (normal left inverted right x axis y axis) 338mm x 270mm
	Clones:     VGA-1
	CRTC:       1
	CRTCs:      0 1
S-video disconnected (normal left inverted right x axis y axis)
	Clones:    
	CRTCs:      0 1