Configure DVI Modelines with xrandr in X11

Configuring custom display resolutions and refresh rates for DVI outputs under the X11 windowing system relies on calculating specific timing parameters and injecting them dynamically using the xrandr utility. This guide explains how X11 handles DVI video timings, how to calculate custom modelines within DVI bandwidth constraints, and the precise sequence of xrandr commands required to declare, bind, and activate a new display mode.

How Modelines Work in X11

A modeline is a configuration string that instructs the graphics card's display controller how to drive a monitor. It defines the pixel clock frequency, active visible resolution, and the front porch, sync pulse, and back porch timings for both horizontal and vertical scan lines.

When dealing with DVI (Digital Visual Interface), the timing parameters must adhere to hardware limitations:

  • Single-Link DVI has a maximum pixel clock of 165 MHz, supporting up to 1920x1200 at 60 Hz or 2560x1600 with reduced blanking.
  • Dual-Link DVI supports higher bandwidth by using a second transmitter, allowing higher pixel clocks for resolutions such as 2560x1600 or 144 Hz refresh rates.

Step 1: Identify the DVI Output

Query the X11 server to locate the active or connected DVI interface name:

xrandr -q

In the output, identify your DVI connector. Typical names assigned by display drivers include DVI-0, DVI-1, DVI-I-1, or DVI-D-0. Note this exact identifier for subsequent commands.

Step 2: Generate the Modeline

Use the Coordinated Video Timings (CVT) standard utility to calculate the required signal timings for your desired resolution and refresh rate.

For standard timings:

cvt 1920 1080 60

To fit within single-link DVI's 165 MHz pixel clock limit at high resolutions, generate a reduced blanking modeline using the -r flag:

cvt -r 1920 1080 60

The output will provide a Modeline string similar to:

Modeline "1920x1080R"  138.50  1920 1968 2000 2080  1080 1083 1088 1111 +hsync -vsync

Step 3: Register the Modeline with X11

Create the mode in the running X server using xrandr --newmode. Exclude the word "Modeline" and pass the rest of the generated string:

xrandr --newmode "1920x1080R" 138.50 1920 1968 2000 2080 1080 1083 1088 1111 +hsync -vsync

This registers the timing profile globally in X11's internal mode pool, but it is not yet attached to any physical hardware port.

Step 4: Associate the Mode with the DVI Output

Link the newly registered mode to your specific DVI interface using --addmode:

xrandr --addmode DVI-1 "1920x1080R"

This validates the timing parameters against the driver’s capabilities for that specific output port.

Step 5: Activate the New Mode

Instruct X11 to switch the DVI display to the new configuration:

xrandr --output DVI-1 --mode "1920x1080R"

The display controller will immediately reprogram the pixel clock and sync signals over the DVI link to match the defined modeline.

Persisting the Configuration

Modes created via xrandr exist only in memory and are reset when the X server restarts. To make these changes permanent, add the execution commands to the desktop session startup script (such as ~/.xprofile or ~/.xinitrc), or define a custom Monitor section containing the Modeline within an Xorg configuration file in /etc/X11/xorg.conf.d/10-monitor.conf.