Site Tools


Sidebar

snippets:linux_4k_output

Table of Contents

What?

Notes on 4k output on Linux. I use Fedora22. Output is

  • mini displayport 1.1a, coming out of a Thinkpad x230
  • adapter cable mini-Displayport to HDMI (Moshi Mini DisplayPort to HDMI Adapter (4K) silver), a second adapter cable behaves identically
  • Samsung UE40HU6900S TV, has 3 HDMI ports, all 3 accepting 4k (so apparently HDMI2 capable)

Notes

  • First verifying the smallest 4k modes which the TV can display. Here manual page 233ff: 3840×2160 with 24/25/30Hz and 4096×2160 with 24Hz
  • I was not able to see any 4k modes available when running “xrandr”, so had to create custom modelines.
  • These can be created manually or with “cvt”:
cvt 3840 2160 13.8  # I added this for testing
cvt 3840 2160 24
cvt 3840 2160 25
cvt 3840 2160 30
cvt 4096 2160 24

### example output:
$ cvt 3840 2160 25
# 3840x2160 24.97 Hz (CVT) hsync: 54.79 kHz; pclk: 278.75 MHz
Modeline "3840x2160_25.00"  278.75  3840 4064 4464 5088  2160 2163 2168 2194 -hsync +vsync
  • Some howtows guide at this point to modify xorg.conf (i.e. creating /etc/X11/xorg.conf.d/11-monitor.conf) but we can test the new modes more flexible without doing that.
  • As I noticed later, the modes from the normal 'cvt' tool did not work out, I need ones without blanking. See here and here for details.
### lets get newest cvt12 which can remove blank lines:
$ wget https://raw.githubusercontent.com/kevinlekiller/cvt_modeline_calculator_12/master/cvt12.c 
$ gcc cvt12.c -O2 -lm -Wall -o cvt12
$ ./cvt12 3840 2160 25 -b
# 3840x2160 @ 25.000 Hz Reduced Blank (CVT) field rate 25.000 Hz; hsync: 54.850 kHz; pclk: 219.40 MHz
Modeline "3840x2160_25.00_rb"  219.40  3840 3888 3920 4000  2160 2183 2188 2194 +hsync -vsync

### now generate modelines for screenmodes which
### might work out for us
$ for i in 25 30 50 60; do \
    ./cvt12 3840 2160 $i -b >>modelines.txt; done
$ for i in 24 25 30; do \
    ./cvt12 4096 2160 $i -b >>modelines.txt; done

### Now we need to configure Xorg with the modelines.
### We can paste these xrandr-lines in a terminal.
$ grep Modeline modelines.txt | \
    sed -e 's,Modeline,xrandr --newmode,'
xrandr --newmode "3840x2160_25.00_rb" 219.40  3840 3888 3920 4000  2160 2183 2188 2194 +hsync -vsync
xrandr --newmode "3840x2160_30.00_rb" 263.28  3840 3888 3920 4000  2160 2183 2188 2194 +hsync -vsync
xrandr --newmode "3840x2160_50.00_rb" 442.20  3840 3888 3920 4000  2160 2183 2188 2211 +hsync -vsync
xrandr --newmode "3840x2160_60.00_rb" 533.28  3840 3888 3920 4000  2160 2183 2188 2222 +hsync -vsync
xrandr --newmode "4096x2160_24.00_rb" 224.61  4096 4144 4176 4256  2160 2183 2193 2199 +hsync -vsync
xrandr --newmode "4096x2160_25.00_rb" 233.97  4096 4144 4176 4256  2160 2183 2193 2199 +hsync -vsync
xrandr --newmode "4096x2160_30.00_rb" 280.77  4096 4144 4176 4256  2160 2183 2193 2199 +hsync -vsync

### Now we need to configure our HDMI1 output for the modes
$ cat modelines.txt |grep Modeline| \
    sed -e 's," .*,",' -e 's,.* ",xrandr --addmode HDMI1 ",'
xrandr --addmode HDMI1 "3840x2160_25.00_rb"
xrandr --addmode HDMI1 "3840x2160_30.00_rb"
xrandr --addmode HDMI1 "3840x2160_50.00_rb"
xrandr --addmode HDMI1 "3840x2160_60.00_rb"
xrandr --addmode HDMI1 "4096x2160_24.00_rb"
xrandr --addmode HDMI1 "4096x2160_25.00_rb"
xrandr --addmode HDMI1 "4096x2160_30.00_rb"


# now start watching the x.org log
tail -f /var/log/Xorg.0.log &

### and set the mode
$ xrandr --output HDMI1 --verbose --mode 3840x2160_13.80
crtc 1: 3840x2160_13.80  13.79 +0+768 "HDMI1"

xorg-log: (--) intel(0): HDMI max TMDS frequency 300000KHz
=> This is a mode the intel chip can output,
   but the TV can not display

### setting 4k 25Hz mode successfully:
$ xrandr --output HDMI1 --verbose --mode 3840x2160_25.00_rb
crtc 1: 3840x2160_25.00_rb  25.00 +0+768 "HDMI1"
xorg-log: (--) intel(0): HDMI max TMDS frequency 300000KHz
=> successfully switches the mode to 4k

### attempting to set 4k 30Hz, not successful:
$ xrandr --output HDMI1 --verbose --mode 3840x2160_30.00_rb
crtc 1: 3840x2160_30.00_rb  30.00 +0+768 "HDMI1"
xrandr: Configure crtc 1 failed
crtc 0: disable
crtc 1: disable
crtc 2: disable
crtc 3: disable
screen 0: revert
crtc 0: revert
crtc 1: revert
crtc 2: revert
crtc 3: revert
xorg-log: (EE) intel(0): failed to set mode: Invalid argument [22]

Modes

mode status
3840x2160_25.00_rbworks for me
3840x2160_30.00_rbnot working
3840x2160_50.00_rbnot working
3840x2160_60.00_rbnot working
4096x2160_24.00_rbworks for me
4096x2160_25.00_rbnot working
4096x2160_30.00_rbnot working
  • Thinkpad x230, “Intel(R) HD Graphics 4000”: 3840×2160 with 25Hz possible
  • Thinkpad x200, “Intel(R) GM45”: 3840×2160 was not possible for me, “intel(0): failed to set mode: Invalid argument”

Final script

xrandr --newmode "3840x2160_25.00_rb" \
  219.40  3840 3888 3920 4000  2160 2183 2188 2194 +hsync -vsync
sleep .5
xrandr --addmode HDMI1 "3840x2160_25.00_rb"
sleep .5
xrandr --output HDMI1 --verbose --mode 3840x2160_25.00_rb \
  --below LVDS1
snippets/linux_4k_output.txt · Last modified: 2024/03/03 11:41 by chris