Getting HDMI output to work with switchable graphics on Arch Linux

I’ve been trying to get the HDMI output to work properly with switchable graphics activated. I posted a question in the Arch Linux forum on Reddit, and I got the feedback that is caused by the HDMI port being attached to the discrete GPU and the integrated GPU does not know how to access it without unless reverse PRIME is configured properly. Based on the Arch Wiki’s entry on the topic and feedback on Reddit, I’ve tried configuring it as following. However, it is not working as it should. I was hoping someone in this forum with had had luck setting it up correctly.

Example setup:

% xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x43 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 1 associated providers: 1 name:modesetting
Provider 1: id: 0x275 cap: 0x2, Sink Output crtcs: 4 outputs: 6 associated providers: 1 name:NVIDIA-G0

% lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GA104M [GeForce RTX 3070 Mobile / Max-Q] (rev a1)
05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] (rev c5)

% nano /etc/X11/xorg.conf

Section "ServerLayout"
Identifier "layout"
Screen 0 "amdgpu"
Inactive "nvidia"
Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:1:0:0"
EndSection

Section "Screen"
Identifier "nvidia"
Device "nvidia"
EndSection

Section "Device"
Identifier "amdgpu"
Driver "modesetting"
BusID "PCI:5:0:0"
EndSection

Section "Screen"
Identifier "amdgpu"
Device "amdgpu"
EndSection

% xrandr --setprovideroutputsource NVIDIA-G0 modesetting

% xrandr --auto
xrandr: Configure crtc 4 failed

% xrandr --setprovideroffloadsink modesetting NVIDIA-G0
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 140 (RANDR)
Minor opcode of failed request: 34 (RRSetProviderOffloadSink)
Value in failed request: 0x43
Serial number of failed request: 16
Current serial number in output stream: 17

Tech specs:

Host: 82JY Legion 5 17ACH6H
Kernel: 6.1.11-arch1-1
DE: GNOME 43.2
CPU: AMD Ryzen 7 5800H with Radeon Graphics (16) @ 3.200GHz [44.2°C]
GPU: NVIDIA GeForce RTX 3070 Mobile / Max-Q
GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series
Memory: 4.57GiB / 29.24GiB
GPU Driver: NVIDIA 525.89.02

Please set kernel parameter
nvidia-drm.modeset=1
and rather delete your xorg.conf so amdgpu is used instead of modesetting.
Then run
xrandr --setprovideroutputsource 1 0 && xrandr --auto
to enable the outputs on the nvidia gpu.

1 Like

Thanks for you reply. Your solution brings me a bit closer to the desired outcome:

Following these steps I now got a picture on my HDMI output. However, I am only able to mirror the laptop screen. I was unable to apply joined screens (and presumably also HDMI output only) in the Gnome display settings. Furthermore, the display on HDMI output is lost after rebooting the computer. I would have thought setting xrandr --setprovideroutputsource 1 0 && xrandr --auto would solve the issue, since these weren’t added to ~/xinitrc. However, this didn’t work, which makes me suspect that the modeset kernel parameter is no longer set to 1.

Steps taken:

  1. Logged out of user, and pressing Ctrl+Alt+F2 to enter text console.

  2. In order to disable the display manager and enable DRM KMS support (see graphics driver README and Installation guide), I logged in as root in text console, and typed the following commands:

# Disable the graphical target, which is what keeps the display manager running:
% systemctl isolate multi-user.target

# Enable NVIDIA's DRM KMS support:
% modprobe -r nvidia_drm
% modprobe nvidia_drm modeset=1

# Start the graphical environment again:
% systemctl start graphical.target
  1. Log into user account, and set
xrandr --setprovideroutputsource 1 0 && xrandr --auto

in terminal. At this point I got a picture on my monitor connected to the HDMI port. However, I was unable to change to “joined” display settings, or get output on HDMI only.

  1. I then rebooted. The settings seem now to have reverted. I now get the same error as earlier:
% sudo xrandr --setprovideroutputsource 1 0
% sudo xrandr --auto                       
xrandr: Configure crtc 4 failed

How can I make HDMI output stick after reboot? Should I set it GRUB_CMDLINE_LINUX_DEFAULT in GRUB’s config file? And how can I set screen outputs to joined outputs with independent resolutions, or just HDMI?

https://wiki.archlinux.org/title/NVIDIA

Thanks for the tip. I did set the kernel parameter nvidia_drm.modeset=1 in /etc/default/grub. I now get picture on both screens when logging into my user with “Switchable graphics” activated in the UEFI settings. This is progress!

However, the screens are mirrored by default, and I am unable to change the display settings to “Join” in Gnome’s display settings, or just use external monitor only. Under “Known Issues” in the installation guide’s page on DRM KMS, it is stated:

“The NVIDIA DRM KMS implementation is currently incompatible with SLI Mosaic. The X server will fail to initialize SLI Mosaic if DRM KMS is enabled.”

Is this the reason joined screens are not working? If not, what am I missing here?

Mossaic is for running multi-gpu with quadros, so doesn’t matter in your case.
Getting only mirrored output might be just a bug in gnome-settings, maybe using xrandr directly will make it work. Please create a new nvidia-bug-report.log.

1 Like

Update:

Ok, so I thought about your first reply. It occurred to me I never actually installed the xf86-video-amdgpu drivers, only the mesa (modesetting) drivers.

What works

I can confirm that after installing the amdgpu drivers and rebooting with the nvidia-drm.modeset=1 kernel parameter, GNOME will start with joined screens by default.

What didn’t work
  1. I get strange behaviour when trying to use external monitor only. For some reason, this causes the screen to be very “choppy” and there’s an input lag of several seconds from mouse and keyboard.
  2. Also, trying to change screen settings using xrandr resulted in a less than desirable outcome. For example, setting xrandr --output eDP --primary --auto --output HDMI-1-0 --right-of eDP --auto resulted in a frozen output in the upper left quarter of the external monitor.

The good news is I can now, seemingly, use HDMI output with switchable graphics. However, there’s still the lag issue of using external monitor only, which I do not fully understand. Any idea what’s causing this?

Known bug in recent driver versions.

1 Like

https://forums.developer.nvidia.com/t/525-60-11-breaks-composited-desktop-on-x11-if-laptop-lid-is-closed/236181/5

1 Like

Ok, that’s unfortunate. Hopefully there will be a fix soon.

…and thank you so much for your help! I’ve been pulling my hair over this for weeks! Now I feel can finally move on for the time being.

@generix So, composited desktop was working fine until yesterday, when it suddenly stopped working out of the blue. I am now only able to use screen mirroring. Worse, I am unable to identify any actions on my part that may have caused joint screens to stop working. Any ideas how to resolve it?

Please create a new nvidia-bug-report.log

Here it is: nvidia-bug-report.log.gz (346.9 KB)

No idea, looks like gnome is setting the correct mode first, then resets it.

I assume this is a bug and should be reported then. However, I’m not sure whether this should be considered a graphics driver issue or a desktop environment issue. (Although, given that setting composite displays doesn’t work in xrandr and that discrete graphics works flawlessly in GNOME, I am prone to think this is more of a driver issue. )

Do you have a recommendation on where it should be reported?

IDK, since no errors are reported. What happens when you run
xrandr --fb 3840x1080 --output eDP --pos 0x0 --output HDMI-1-0 --mode 1920x1080 --pos 1920x0

Ok, an interesting observation upon boot is that composited displays seems to work in the login screen: I get the login menu only on my external monitor, while my laptop screen only show the background.

I tried running

xrandr --fb 3840x1080 --output eDP --pos 0x0 --output HDMI-1-0 --mode 1920x1080 --pos 1920x0

At first I get picture only on my laptop’s integrated display, and my external monitor goes dark (backlight is still on). However, there is no menu on the laptop screen, inidcating it is seen as as secondary display. I then tried locking my screen using a keyboard shortcut (Super + L).

The login screen now displayed a composited desktop, with the login menu displayed on my external monitor. When logging in, I now have correctly displayed composited desktop, with HDMI set as primary display in GNOME’s display settings. The external monitor’s resolution is now limited to 1920×1080 (it’s a 4K display), but I suppose that’s only to be expected given the command presets…? (I assume the --fb flag sets the full desktop width, and --mode the external monitors resolution…?)

nvidia-bug-report.log.gz (361.5 KB)


[Update:]

So it turns out I am able to set composited displays with xrandr.
The following command set the resolutions and postions correctly:

xrandr --output eDP --mode 1920x1080 --rate 144.00 --output HDMI-1-0 --primary --mode 3840x2160 --rate 59.94 --below eDP

However, this leads to my external monitor displaying very small icons and text (scale 100%). I tried setting a different scale using the --scale flag (e.g. --scale 2x2), but this doesn´t really increase the size of the text, and instead leads to part of the display being outside the screen.

Attempts:

# Leads to display outside screen boundaries:
xrandr --output eDP --mode 1920x1080 --rate 144.00 --output HDMI-1-0 --primary --mode 3840x2160 --rate 59.94 --below eDP --scale 2x2

xrandr --fb 3840x3240 --output eDP --mode 1920x1080 --rate 144.00 --output HDMI-1-0 --primary --mode 3840x2160 --rate 59.94 --below eDP --scale 2x2

# Leads to display in upper quarter of screen:
xrandr --output eDP --mode 1920x1080 --rate 144.00 --output HDMI-1-0 --primary --mode 3840x2160 --rate 59.94 --below eDP --scale 0.5x0.5

xrandr --fb 3840x3240 --output eDP --mode 1920x1080 --rate 144.00 --output HDMI-1-0 --primary --mode 3840x2160 --rate 59.94 --below eDP --scale 0.5x0.5

Is there a way I can set display to scale/zoom correctly?
Given that setting composited displays seem to work with Xrandr, presumably this is a GNOME issue then?

Please try deleting ~/.config/monitors.xml and reboot immediately. After logging in, please try arranging your monitors using gnome settings again.

That did temporarily solve the issue!

However it’s still buggy at best. External monitor will freeze on screen lock and then lose output completely. After a few seconds, the login screen will appear on the laptop monitor and I am able to unlock the screen. I then have to go back into GNOME display settings. At first it’ll detect only the laptop monitor, until I set “Multiple Displays>Mirror”. At this point both screens appear in the settings, and I am able to set “Multiple Displays>Join” again. Composited displays now works again for the time being, presumably until the screen is locked again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.