Multi-head configuration on an Optimus laptop (hybrid graphics)

Hello. Could you please advice how to solve the following issue?

The setup

I have 3 external monitors connected to a Dell laptop via a one HDMI output (3440x1140) and a USB-C hub with two display ports (both 1920x1080) with the following videocards. The HDMI output is served by the discrete, i.e. NVIDIA, videocard.

Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] driver: vgapci
Device-2: NVIDIA GP107M [GeForce GTX 1050 Ti Mobile] driver: vgapci


The laptop's BIOS does not allow to set which videoadapter to use.

I use X.org with an XFCE desktop environment. The OS version is
FreeBSD lmalaptop 13.3-RELEASE-p5 FreeBSD 13.3-RELEASE-p5 GENERIC amd64

I attached the Xorg.log, rc.conf, and xorg.conf (/usr/local/etc/X11/xorf.conf.d is empty) to the bottom of the post. From the Xorg.log, it is clearly seen that both videadapters are enabled, 3 monitors which are connected to iGPU are seen (i.e. EDID can be loaded), and the widest monitor which is connected to dGPU is recognised by Xorg as well.

xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x1b7 cap: 0x0 crtcs: 4 outputs: 1 associated providers: 0 name:NVIDIA-0
Provider 1: id: 0x206 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 6 associated providers: 0 name:modesetting


kldstat
...
4 1 0xffffffff834f9000 125658 nvidia-modeset.ko
5 1 0xffffffff83800000 3117fe0 nvidia.ko
6 2 0xffffffff8361f000 31958 linux.ko
7 6 0xffffffff83651000 be20 linux_common.ko
8 1 0xffffffff8365d000 17f8b8 i915kms.ko
9 1 0xffffffff86918000 72bd8 drm.ko
10 1 0xffffffff837dd000 22b0 iic.ko
11 2 0xffffffff837e0000 30fc linuxkpi_gplv2.ko
12 3 0xffffffff837e4000 62d8 dmabuf.ko
13 1 0xffffffff8698b000 2dca8 linux64.ko
...


The goal

I need to enable all of the monitors and expand desktop environment across them, i.e. to move windows, mouse cursor, etc. across the monitors. Before I start to use FreeBSD on my laptop, I was successful to achieve the goal on Linux Manjaro out of the box.

As far as I know, this is done using Offloading Graphics Display with RandR mode which is described here. Following this guide, I was not able to achive the goal neither using nvidia-xconfig nor manual editing of Xorg configuration.

I do not need to execute an application like a game or graphics software using dGPU, so the PRIME Render Offload mode (described here) is not an appropriate option for me.

The issue


So far, I was able to output my XFCE desktop either to the HDMI-connected monitor or to 3 monitors (including the built-in one). I am not able to output the desktop to any combination of the monitors like I did on Manjaro.

I was able to manually setup Xorg using a configuration file to expand desktop to another screens. But monitors remain unusable (i.e. black and only mouse cursor can be moved to them not windows). The XFCE Display settings, xrandr -q and nvidia-settings show only one monitor which is connected to dGPU, or, If I remove any Xorg configuration files (which is by deafult), the 3 monitors which are connected to iGPU show up only (it is possible to share the desktop across these 3 monitors but the widest monitor remains unusable).

P.S. I would like to avoid to use two X servers. If it is the only option for now, please help me to write a correct Xorg configuration.
 

Attachments

The common way (at least as I did it) is to add a xrand line to your ~/.xinitrc:

Code:
xrandr --output HDMI-0 --mode 1920x1080 --rotate normal --output DP-2 --mode 1920x1200 --rotate left --right-of HDMI-0 --output DP-4 --mode 1920x1200 --rotate normal --right-of DP-2 --output DP-0 --mode 1920x1200 --rotate left --left-of HDMI-0
to do it relatively.
To do it absolute you may exchange '--right-of ...' with '--pos XxY'
Because of different monitors with different solutions, different pixel-shapes, rotation, and position you may get a prob to find your mousepointer sometimes ? (That's what XEyes is for - binded it to a key)
Code:
xrandr --output HDMI-0 --mode 1920x1080 --rotate normal --pos 1200x400 --output DP-2 --mode 1920x1200 --rotate left --pos 3120x0 --output DP-4 --mode 1920x1200 --rotate normal --pos 4320x450 --output DP-0 --mode 1920x1200 --rotate left --pos 0x0

you need to test out which monitor at which connector will be 1, 2, 3 ... (I never figured out any comprenhendable way but guessing, why which becomes which, except the graphics adapter may have some primary port (which of course is not documented nowhere), and like on the SATA ports of the drives: the first one detected (the fastest one responses) becomes 1 - maybe so; just try it out.)

you may see my config on
forums/Desktop Usage/Display Servers/FreeBSD Screen Shots/mid of p90

However, with laptops it could be kind of bit more tricky, since they also have such features to switch between graphics outputs for presentation.
 
I was able to manually setup Xorg using a configuration file to expand desktop to another screens. But monitors remain unusable (i.e. black and only mouse cursor can be moved to them not windows).

Does this help?

 
The common way (at least as I did it) is to add a xrand line to your ~/.xinitrc:

Code:
xrandr --output HDMI-0 --mode 1920x1080 --rotate normal --output DP-2 --mode 1920x1200 --rotate left --right-of HDMI-0 --output DP-4 --mode 1920x1200 --rotate normal --right-of DP-2 --output DP-0 --mode 1920x1200 --rotate left --left-of HDMI-0
to do it relatively.
To do it absolute you may exchange '--right-of ...' with '--pos XxY'
Because of different monitors with different solutions, different pixel-shapes, rotation, and position you may get a prob to find your mousepointer sometimes ? (That's what XEyes is for - binded it to a key)
Code:
xrandr --output HDMI-0 --mode 1920x1080 --rotate normal --pos 1200x400 --output DP-2 --mode 1920x1200 --rotate left --pos 3120x0 --output DP-4 --mode 1920x1200 --rotate normal --pos 4320x450 --output DP-0 --mode 1920x1200 --rotate left --pos 0x0

you need to test out which monitor at which connector will be 1, 2, 3 ... (I never figured out any comprenhendable way but guessing, why which becomes which, except the graphics adapter may have some primary port (which of course is not documented nowhere), and like on the SATA ports of the drives: the first one detected (the fastest one responses) becomes 1 - maybe so; just try it out.)

you may see my config on
forums/Desktop Usage/Display Servers/FreeBSD Screen Shots/mid of p90

However, with laptops it could be kind of bit more tricky, since they also have such features to switch between graphics outputs for presentation.
Thank you for the advice. It does not work as xrandr does not see other monitors connected. They are seen in Xorg.0.log (see the original post) but not by xrandr. So, when I try to set up an output I am receiving

warning: output <output_name> not found; ignoring

root@lmalaptop: # xrandr
Screen 0: minimum 8 x 8, current 3440 x 1440, maximum 32767 x 32767
HDMI-0 connected 3440x1440+0+0 (normal left inverted right x axis y axis) 797mm x 334mm
3440x1440 59.97*+ 99.98 29.97
2560x1440 120.00 59.95
2560x1080 100.00 59.94
1920x1080 120.00 119.88 100.00 100.00 60.00 59.94 50.00 29.97
1680x1050 59.95
1440x900 59.89
1280x1024 75.02 60.02
1280x960 60.00
1280x800 59.81
1280x720 59.94 50.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
720x576 50.00
640x480 75.00 72.81 59.94
 
Does this help?

This worked. I replaced nvidia-modeset with nvidia-drm-510-... and set it up according to the post, and all 4 monitors are seen now by xrandr.

Thank you for help.
 
Back
Top