# Xorg AMDGPU

I own a AMD Vega64 and an using it with i3 on Manjaro. The misaligned monitors on the greeter and the manual resolution and refresh rate switching were super annoying. 

# Setup

* Updated Manjaro with kernel >5.0 including amdgpu kernel driver 
* AMD Vega64
* Monitor capable of 144Hz and Freesync
* Second Monitor not capable of those things

# 144Hz modline

This was relative simple, amdgpu is pretty verbose on startup and prints *all* available modlines for the connected outputs on the card into `/var/log/Xorg.0.log`.
With a simple `less /var/log/Xorg.0.log` I quickly found it somehwere along with 
```
[     6.454] (II) AMDGPU(0): Printing probed modes for output DisplayPort-2
[     6.454] (II) AMDGPU(0): Modeline "2560x1440"x60.0  241.50  2560 2608 2640 2720  1440 1443 1448 1481 +hsync -vsync (88.8 kHz eP)
[     6.454] (II) AMDGPU(0): Modeline "2560x1440"x143.9  586.00  2560 2568 2600 2640  1440 1465 1473 1543 +hsync -vsync (222.0 kHz e)
[     6.454] (II) AMDGPU(0): Modeline "2560x1440"x119.9  482.64  2560 2568 2600 2640  1440 1447 1455 1525 +hsync -vsync (182.8 kHz e)
[     6.454] (II) AMDGPU(0): Modeline "2560x1440"x99.9  398.23  2560 2568 2600 2640  1440 1496 1504 1510 +hsync -vsync (150.8 kHz e)
```
and used the one with my desired configuration. 

# xorg config 

To get my setup working as expecting without manual configuration on every startup, I needed to place a persistent config in the xorg config folder so e.g. `/etc/X11/xorg.conf.d/10-monitors.conf`. 
There, I configured both my GPU driver and the monitors like following. 

The *Monitor* sections are straightforward.
*DisplayPort-2* is my 144Hz display, so I added the modline as a new preset `2560x1440_full` and used it in the *PreferredMode* option. 
Further I enabled DPMS, the *Display Power Management Signaling* so the system could turn of the Montiors just in case. 

The *Device* section contains the preferred options for the given GPU drive, in my case *amdgpu*. 
I enabled *TearFree* as well as *VariableRefresh*, the first one should reduce tearing on both displays while the latter one enables FreeSync on my 144Hz monitor. 
After a reboot, my monitor indeed reported it was using FreeSync!


```
Section "Monitor"
  Identifier "DisplayPort-2"
  Modeline "2560x1440_full"  586.00  2560 2568 2600 2640  1440 1465 1473 1543 +hsync -vsync
  Option "Primary" "true"
  Option "PreferredMode" "2560x1440_full"
  Option "DPMS" "true"
EndSection

Section "Monitor"
  Identifier "DisplayPort-1"
  Option "PreferredMode" "2560x1440_59.95"
  Option "LeftOf" "DisplayPort-2"
  Option "DPMS" "true"
EndSection

Section "Device"
  Identifier "AMD-VEGA"
  Driver "amdgpu"
  Option "VariableRefresh" "true"
  Option "TearFree" "true"
EndSection
```