# Setting up an AMD RX550 and a 4k monitor

## Ant P.

This post is half documentation of what I got working so far, and half questions: I've figured most things out, but there's still a lot of rough edges.

Configuring the kernel (I'm using 4.14.5) is straightforward enough: followed the wiki page for amdgpu, with one trap - the RX550 is a polaris12, so new that it wasn't listed on multiple sites including the DRI wiki. Be aware of that when putting its firmware in the kernel. I guessed wrong the first time and had to fix it over ssh.

Configuring userspace involves tweaking USE flags, not much else. Here's what I did:

```
# stuff like opengl omitted here for brevity

*/* VIDEO_CARDS: -* amdgpu radeon

media-libs/mesa VIDEO_CARDS: radeonsi

sys-devel/* LLVM_TARGETS: -* AMDGPU

x11-base/xorg-server glamor
```

```
emerge -DatvuN @world
```

I installed that kernel and shut down to put the card in, then rebooted. (@Neddy: looks like there were no fireworks after all  :Smile:  )

After reboot, kernel console fonts are ridiculously tiny and barely readable even with my good eyesight. I'm using X mostly so I can ignore that for now and tweak /etc/conf.d/consolefont later.

X11 segfaulted first time because I had my old radeon settings in the config file. The fancontrol service broke too, it doesn't like when things show up at the same PCI address with different names.

Made sure the xorg.conf Device section has Driver "amdgpu" and nothing else, and now it starts up.

...but now everything in X11 is unreadably tiny!

This confused me for a few minutes because new programs are supposed to be hidpi-aware, aren't they? Turns out something's doing something stupid in the graphics stack and forcing the display to 96dpi. `xrandr` shows the real physical size from EDID though, so I put that into xorg.conf. The full thing now contains this:

```
Section "Monitor"

    Identifier "LG 4k"

    DisplaySize 600 340

    Option "Primary"

EndSection

Section "Device"

    Identifier "Radeon"

    Driver "amdgpu"

    Option "Monitor-DisplayPort-0" "LG 4k"

EndSection
```

Restarted X and with that, things are in a much more usable state:

Everything Mesa-related I've tested works perfectly. OpenGL, VDPAU, etc.

Web browsers now look pretty great, as I'd expect.

Suckless tools (dmenu and st) are surprisingly well behaved and scaled automatically (it helps that I specify fonts in points, i.e. $fontname $pt instead of the xft $fontname:pixelsize=$px syntax)

dunst and tint2 needed a lot of reconfiguring

GTK2 is usable for the most part, though the icons are microscopic (I thought SVG was supposed to fix all that? Surely there's a setting somewhere...)

Openbox window controls are tiny, though I didn't need to tweak the font size.

Java stuff (using GTK2 theming) makes a horrible mess of everything by double-applying the scale factor. Fortunately I don't have much of this to deal with.

My mouse cursor is tiny, except in some parts of GTK2 windows where it uses the default cursor theme for no apparent reason. Slightly annoying, not sure what to do here.

One last problem: I'm getting no sound. The card shows up in alsamixer with 5(?!) S/PDIF outputs, /proc/asound/HDMI/codec#0 looks normal for a HDA codec, and I can get pulseaudio to recognise it too, but I'm failing to get anything out of it but silence. I've read some things saying amdgpu is still missing audio stuff that won't show up until kernel 4.15, maybe that's the problem...

----------

## BT

Thank you for the post. The info will be useful when I get my LG 27UD69 and RX 550. Which LG monitor do you have?

----------

## Marlo

Do you have that in the kernel?

```
CONFIG_DRM_AMD_ACP:                                                                                                                                                                           

                                                                          

   Location:                                                                                                                                                                                     

     -> Device Drivers                                                                                                                                                                           

       -> Graphics support                                                                                                                                                                        

        -> ACP (Audio CoProcessor) Configuration                
```

edit:

I could be wrong, but the following works for me.

For your concern, the collected kernel options for amdgpu and amdgpu-pro:

```

CONFIG_MTRR = y

# CONFIG_TRIM_UNUSED_KSYMS is not set

CONFIG_MTRR_SANITIZER = y

CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT = 1

CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT = 2

CONFIG_BINFMT_ELF=y

CONFIG_COMPAT_BINFMT_ELF=y

CONFIG_BINFMT_SCRIPT=y

CONFIG_BINFMT_MISC=y

CONFIG_FW_LOADER = y

CONFIG_FIRMWARE_IN_KERNEL = y

CONFIG_EXTRA_FIRMWARE = "amdgpu/polaris11_ce.bin amdgpu/polaris11_mc.bin amdgpu/polaris11_me.bin amdgpu/polaris11_mec2.bin amdgpu/polaris11_mec.bin amdgpu/polaris11_pfp.bin amdgpu/polaris11_rlc.bin amdgpu/polaris11_sdma1.bin amdgpu/polaris11_sdma.bin amdgpu/polaris11_smc.bin amdgpu/polaris11_smc_sk.bin amdgpu/polaris11_uvd.bin amdgpu/polaris11_vce.bin"

CONFIG_EXTRA_FIRMWARE_DIR = "/lib/firmware"

CONFIG_AGP = y

CONFIG_VGA_SWITCHEROO = y

CONFIG_DRM = y

CONFIG_DRM_FBDEV_EMULATION = y

CONFIG_DRM_AMDGPU = m

CONFIG_DRM_AMD_ACP=y/etc/X11/xorg.conf.d # cat 10-device.conf 

CONFIG_DRM_AMDGPU_USERPTR = y

CONFIG_FB = y

CONFIG_FB_MODE_HELPERS = y

CONFIG_FB_VESA = y

# CONFIG_DRM_RADEON is not set

# CONFIG_FB_RADEON is not set

DEBUG_KERNEL = n

```

and it could not hurt if your file /etc/X11/xorg.conf.d/output.conf has this Section "Device"

```

/etc/X11/xorg.conf.d # cat 10-device.conf 

Section "Device"

   Identifier  "AMD (Your XXXX POLARIS11)"

   Driver      "amdgpu"

   BusID       "PCI:1:0:0"

   Option      "DRI"         "3"

   Option      "AccelMethod" "glamor"

   Option       "TearFree"    "on" 

EndSection

```

You have certainly also activated these USE flags.

```

dri3 egl gbm gallium gles1 gles2 llvm opencl openmax osmesa vaapi vdpau vulkan 
```

It's also a good idea to have llvm and clang in version 5. llvm should be compiled according to phoronix with clang.

clang needs:  LLVM_TARGETS="AMDGPU BPF NVPTX

Ma

----------

## Ant P.

 *BT wrote:*   

> Thank you for the post. The info will be useful when I get my LG 27UD69 and RX 550. Which LG monitor do you have?

 

27UD58 here, I wonder what the difference is.

 *Marlo wrote:*   

> Do you have that in the kernel?
> 
> ```
> CONFIG_DRM_AMD_ACP:
> 
> ...

 

```
 ~ $ zgrep -E '^CONFIG_DRM|HDMI|amdgpu' /proc/config.gz

CONFIG_EXTRA_FIRMWARE="amdgpu/polaris12_ce_2.bin amdgpu/polaris12_ce.bin amdgpu/polaris12_mc.bin amdgpu/polaris12_me_2.bin amdgpu/polaris12_me.bin amdgpu/polaris12_mec2_2.bin amdgpu/polaris12_mec_2.bin amdgpu/polaris12_mec2.bin amdgpu/polaris12_mec.bin amdgpu/polaris12_pfp_2.bin amdgpu/polaris12_pfp.bin amdgpu/polaris12_rlc.bin amdgpu/polaris12_sdma1.bin amdgpu/polaris12_sdma.bin amdgpu/polaris12_smc.bin amdgpu/polaris12_uvd.bin amdgpu/polaris12_vce.bin"

CONFIG_DRM=y

CONFIG_DRM_KMS_HELPER=y

CONFIG_DRM_KMS_FB_HELPER=y

CONFIG_DRM_FBDEV_EMULATION=y

CONFIG_DRM_FBDEV_OVERALLOC=100

CONFIG_DRM_TTM=y

CONFIG_DRM_AMDGPU=y

CONFIG_DRM_AMDGPU_USERPTR=y

CONFIG_DRM_AMD_ACP=y

CONFIG_DRM_PANEL=y

CONFIG_DRM_BRIDGE=y

CONFIG_DRM_PANEL_BRIDGE=y

CONFIG_HDMI=y

CONFIG_SND_HDA_CODEC_HDMI=m
```

I was surprised to find out TearFree actually defaults to off in this driver. At least it can be turned on without restarting X:

```
xrandr --output DisplayPort-0 --set TearFree on
```

----------

## Ant P.

Well this is annoying... I restarted X for something unrelated and now GTK3 (i.e. firefox/chromium) thinks my screen is 96dpi; gtk-query-settings shows "gtk-xft-dpi: 98304". Everything else is fine though, and xdpyinfo reports correct values. How can I figure out why GTK's insisting on being wrong?

Edit: worked around it by putting GDK_SCALE=2 in .xsession... but that feels like a dirty hack and something that shouldn't be necessary.Last edited by Ant P. on Sat Dec 23, 2017 6:16 pm; edited 1 time in total

----------

## BT

 *Ant P. wrote:*   

>  *BT wrote:*   Thank you for the post. The info will be useful when I get my LG 27UD69 and RX 550. Which LG monitor do you have? 
> 
> 27UD58 here, I wonder what the difference is.

 

The 27UD69 has a thinner bezel, higher contrast ratio and brightness level.

----------

## Ant P.

Alright, I did a bit more digging with the DPI issue, which needed *more* fixing because gvim compiled with USE=gtk3 ignores GDK_SCALE.

According to this page, GTK3 just completely ignores the X server's DPI and display size entirely, and uses Xft.dpi from Xresources as-is, defaulting to 96dpi just… because. Workaround: set Xft.dpi to what xdpyinfo says it is.

Also from reading that page, it sounds like KDE users are getting a raw deal because it trusts X's defaults (in reality a garbage ~96dpi approximation derived from some faked values, dubious integer math with rounding errors). So if you want fonts to not end up with subtly bad kerning or antialiasing: always set DisplaySize and Xft.dpi!

----------

## firephoto

 *Ant P. wrote:*   

> 
> 
> Also from reading that page, it sounds like KDE users are getting a raw deal because it trusts X's defaults (in reality a garbage ~96dpi approximation derived from some faked values, dubious integer math with rounding errors). So if you want fonts to not end up with subtly bad kerning or antialiasing: always set DisplaySize and Xft.dpi!

 

I just installed  RX 580 the other day and jumped though all the hoops changing over from an nvidia system. DPI has always been a sore spot. The biggest surprise I came across on my first login to the desktop (plasma) was that everything looked the same as before or very close but a quick check of xdpyinfo showed 96 dpi! Recently I had set the Xft.dpi in my ~/.Xresources amd ~/.Xdefaults so plasma, qt, and gtk3 were using that but I still ended up setting up a /etc/X11/xinit/xinitrc.d/95-xrandr config to set the dpi with xrandr so xdpyinfo would show that X was set properly. I couldn't get a xorg.conf.d config to make this work.

```

# /etc/X11/xinit/xinitrc.d/95-xrandr

/usr/bin/xrandr --dpi 157

```

Now here's the real surprise, I tried a wayland session out and after loading it up I checked xdpyinfo and low and behold whatever it loaded for X compatibility actually read the display dimensions and resolution and showed my old auto detected numbers. My display is slightly not pixel square so it shows 157x161 dpi or close. So basically the auto detection from X works here but it's disabled during a normal X session. Sort of sad, funny and annoying.

Overall it's working good with 4k, not much in the way of an upgrade from my gtx 970 but I caught the 580 at normal retail price so I snagged one while it was in stock for a few hours. Still having slow grub issues but I think that's because it works good enough that it is defaulting to a themed grub that redraws slow which wouldn't work with the nvidia setup. Also tty's are too many characters. ""Console: switching to colour frame buffer device 480x135"" that's a lot of characters.

----------

## Ant P.

So after using a correct Xft.dpi setting for a while, I've noticed Chromium really doesn't like it at all. Popup windows for extensions are drawn as non-integer-scaled textures and it looks terrible, the icons on the bookmarks bar are truncated at the bottom too.

So I tried straight up lying to the computer. Xft.dpi is set to 192 now (2.0x) and chromium looks the same as it did originally and other GTK3 stuff also works, but the downside is all my other apps (which read dpi correctly in the first place) now feel way too big.

Question: how can I set a fake DPI for GTK3, and nothing else?

----------

## firephoto

 *Ant P. wrote:*   

> So after using a correct Xft.dpi setting for a while, I've noticed Chromium really doesn't like it at all. Popup windows for extensions are drawn as non-integer-scaled textures and it looks terrible, the icons on the bookmarks bar are truncated at the bottom too.
> 
> So I tried straight up lying to the computer. Xft.dpi is set to 192 now (2.0x) and chromium looks the same as it did originally and other GTK3 stuff also works, but the downside is all my other apps (which read dpi correctly in the first place) now feel way too big.
> 
> Question: how can I set a fake DPI for GTK3, and nothing else?

 

I force chrome scaling, it's auto hidpi or even regular dpi doesn't work very well.

I use the option --force-device-scale-factor=1.6 which after some math and youtube option "stats for nerds" in the right click of a video.. (just what I use for the resolution numbers it gives) make me confident chrome is scaling to the proper size, aka a shown 1080 video with the youtube scaling calculated is taking up 1/4 of the screen.

There's a chromium bug about this issue with gtk3 but it doesn't seem fixed yet even though they claim it was a version or two ago, but for now the scaling option is still there which is good at least for the page content itself.

----------

## Ant P.

New (very annoying) discovery: the HDMI output will run at nonsensical framerates (as low as 40Hz) when audio output is enabled (i.e. the default).

Worked around by running this, but I'm not sure how to make it permanent:

```
xrandr --output HDMI-A-0 --set audio off
```

----------

## firephoto

 *Ant P. wrote:*   

> New (very annoying) discovery: the HDMI output will run at nonsensical framerates (as low as 40Hz) when audio output is enabled (i.e. the default).
> 
> Worked around by running this, but I'm not sure how to make it permanent:
> 
> ```
> ...

 

Not sure if my grub does anything here because I'm not using audio from the video device even though I see the Ellesmere [Radeon RX 580] in the phonon (pulseaudio) device list but it shows it "off". Can't remember where I found the amdgpu.audio=0 info, not in my notes.

Using

```

GRUB_CMDLINE_LINUX= " * other stuff * amdgpu.audio=0"

```

I can't make the displayport create any sound testing it when I enable the profile so the kernel line option might be working.

My xrandr --prop for the displayport display that has audio capability.

```

DisplayPort-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 621mm x 341mm

        EDID: 

                00ffffffffffff000469a32869f30100

                1e180104a53e22783a1cb5a3574fa027

                0d5054bfef00d1c0814081809500b300

                714f81c001014dd000a0f0703e803020

                35006d552100001a04740030f2705a80

                b0588a006d552100001a000000fd001e

                5018a03c041100f0f838f03c000000fc

                0041535553205042323837510a20010a

                020327714f0102031112130414051f90

                0e0f1d1e23091707830100006a030c00

                10000078200000565e00a0a0a0295030

                2035006d552100001ee26800a0a0402e

                60302036006d552100001a011d00bc52

                d01e20b82855406d552100001e8c0ad0

                90204031200c4055006d552100001800

                00000000000000000000000000000064

        TearFree: auto 

                supported: off, on, auto

        dither: off 

                supported: off, on

        scaling mode: None 

                supported: None, Full, Center, Full aspect

        underscan vborder: 0 

                range: (0, 128)

        underscan hborder: 0 

                range: (0, 128)

        underscan: off 

                supported: off, on, auto

        coherent: 1 

                range: (0, 1)

        link-status: Good 

                supported: Good, Bad

   3840x2160     60.00*+  30.00  

   2560x1600     59.97  

   2560x1440     59.95  

   1920x1080     60.00    60.00    50.00    59.94  

   1920x1080i    60.00    50.00    59.94  

   1680x1050     59.88  

   1280x1024     75.02    60.02  

   1440x900      59.90  

   1280x960      60.00  

   1152x864      75.00  

   1280x720      60.00    50.00    59.94  

   1440x576      50.00  

   1024x768      75.03    70.07    60.00  

   1440x480      60.00    59.94  

   832x624       74.55  

   800x600       72.19    75.00    60.32    56.25  

   720x576       50.00  

   720x480       60.00    59.94  

   640x480       75.00    72.81    66.67    60.00    59.94  

   720x400       70.08

```

I don't have any audio related things on any of the video outputs.

----------

## Ant P.

Clean install, same screen setup, and while everything else works fine the tiny mouse cursor problem is back…

Similar symptoms too: Mouse is only properly scaled in firefox (which probably overrides the pointer entirely), it's tiny everywhere else.

`xrandr` shows correct display dimensions, those are set in Xorg.conf, `xrdb -query -all` shows Xft.dpi is set, `gtk-query-settings dpi` shows a right value too.

Every HiDPI document I've read doesn't mention this at all, except to tell you to work around it with a cursor theme. I didn't have one on my old install though and it worked fine.

I don't know what fixed it last time, or I would've written it down here. I wonder if something else is wrong this time.

----------

## firephoto

 *Ant P. wrote:*   

> Clean install, same screen setup, and while everything else works fine the tiny mouse cursor problem is back…
> 
> Similar symptoms too: Mouse is only properly scaled in firefox (which probably overrides the pointer entirely), it's tiny everywhere else.
> 
> `xrandr` shows correct display dimensions, those are set in Xorg.conf, `xrdb -query -all` shows Xft.dpi is set, `gtk-query-settings dpi` shows a right value too.
> ...

 

For my sddm cursor in /etc/environment I have:

```
XCURSOR_SIZE=24
```

24, 36, or 48 would be the normal options for that setting.

I think kde/plasma is doing it's own thing, which might have changed recently because all I see under cursor settings is the size being resolution dependent. My sddm cursor size is different from what I get once I'm logged in because KDE is setting it.

Running dual displays now with my 4k on an xrandr --scaled-from the 1440 resolution so that's why I'm forcing xcursor size in sddm because it was all screwed up with a huge pointer.

----------

