# Laptop Nvidia : Only HDMI Screen...



## Hakaba (Dec 30, 2019)

I have a strange situation (for me).
I install freeBSD 12.1, xorg, xfce, nvidia-driver (build the 440.31 from ports) ...

When I launch startx, the screen of my laptop become black with a little blanc square on top left.
I lost 3-4 hour to discover that if I connect a HDMI monitor, I can see XFCE on it !

xrandr does not know my laptop screen, nvidia-xconfig create a config that didn't work.

Here technicals info :


```
#uname -u
FreeBSD msi 12.1-RELEASE-p1 FreeBSD 12.1-RELEASE-p1 GENERIC  amd64
```


```
#xrandr
Screen 0: minimum 8 x 8, current 3440 x 1440, maximum 32767 x 32767
HDMI-0 connected primary 3440x1440+0+0 (normal left inverted right x axis y axis) 800mm x 335mm
   3440x1440     29.97*+
   1920x1080     60.00    59.94    50.00    29.97    23.98    60.00    50.04
   1680x1050     59.95
   1440x900      59.89
   1280x1024     75.02    60.02
   1280x960      60.00
   1280x800      59.81
   1280x720      60.00    59.94    50.00
   1152x864      75.00
   1024x768      75.03    70.07    60.00
   800x600       75.00    72.19    60.32    56.25
   720x576       50.00
   720x480       59.94
   640x480       75.00    72.81    59.94    59.93
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
```

No files in /etc/X11
file in /usr/local/etc/X11/xorg.conf.d/nvidia-driver.conf attached

let me know if other info can be relevant.


----------



## T-Daemon (Dec 30, 2019)

From  your nvidia-driver.conf:
`Option         "ConnectedMonitor"    "DFP"`

its  "IgnoreEDID*Checksum*", not
`Option      "IgnoreEDIDChacksum" "DFP"`

Comment them both out, try again. From /usr/local/share/doc/NVIDIA_GLX-1.0/html/xconfigoptions.html, assuming the port was build with DOCS option on, 

```
Option "ConnectedMonitor" "string"

        .....  "DFP" should only be used to refer to
           digital flat panels connected via DVI, HDMI, or DisplayPort.
```

In fact it should be enough to configure xorg in /usr/local/etc/X11/xorg.conf.d/nvidia-driver.conf with:

```
Section "Device"
    Identifier  "Card0"
    Driver      "nvidia"
EndSection
```
If something else needs to be configured, it can be appended.


----------



## Hakaba (Dec 30, 2019)

Thanks, I corrected IgnoreEDIDChecksum.

Without the option "ConnectedMonitor", I have a "no device found" error.
I will read the doc (I didn't found it, thanks for the link).


----------



## shkhln (Dec 30, 2019)

Which laptop is this?


----------



## Hakaba (Dec 30, 2019)

shkhln said:


> Which laptop is this?


It is a MSI P65 8RE with a NVidia 1060 MaxQ and Intel core i7-8750H

I try to add DFP-1 and/or DFP-2 in ConnectedMonitor option without success.

I run startx with logverbose 5 :


```
...
[  4648.120] (II) NVIDIA GLX Module  440.31  Sun Oct 27 02:11:10 UTC 2019
[  4648.120] (II) NVIDIA: The X server does not support PRIME Render Offload.
[  4648.521] (--) NVIDIA(0): Valid display device(s) on GPU-0 at PCI:1:0:0
[  4648.521] (--) NVIDIA(0):     DFP-0 (boot)
[  4648.521] (--) NVIDIA(0):     DFP-1
[  4648.521] (--) NVIDIA(0):     DFP-2
...
[  4648.552] (--) NVIDIA(GPU-0): Acer BX340CK (DFP-0): connected
[  4648.552] (--) NVIDIA(GPU-0): Acer BX340CK (DFP-0): Internal TMDS
[  4648.552] (--) NVIDIA(GPU-0): Acer BX340CK (DFP-0): DFP is not internal to notebook
...
A lot of techs characteristics and possibles resolutions
...
[  4648.556] (--) NVIDIA(GPU-0): DFP-1: disconnected
[  4648.556] (--) NVIDIA(GPU-0): DFP-1: Internal DisplayPort
[  4648.556] (--) NVIDIA(GPU-0): DFP-1: DFP is not internal to notebook
...
[  4648.556] (--) NVIDIA(GPU-0): DFP-2: connected
[  4648.556] (--) NVIDIA(GPU-0): DFP-2: Internal TMDS
[  4648.556] (--) NVIDIA(GPU-0): DFP-2: DFP is not internal to notebook
...
```

Neither DFP-0 / DFP-1 / DFP-2 is internal to notebook.
But only this 3 screen exist for the NVidia card...

Is there a way to know why the internal display works before startx is launched ? (maybe it is connected only with the intel card ?)


----------



## shkhln (Dec 31, 2019)

Hakaba said:


> maybe it is connected only with the intel card ?



It is.


----------



## Hakaba (Dec 31, 2019)

How can we know where a screen is connected ?
Is that means we can not have accelerated graphics on the laptop screen (even with Windows) ?
Without «Optimus», I can not have hdmi+laptop screen ?


----------



## shkhln (Dec 31, 2019)

Hakaba said:


> How can we know where a screen is connected ?



We can't, but wiring a laptop screen to a dedicated GPU doesn't make any sense without a multiplexer. In such configuration it wouldn't be possible to turn off the dedicated GPU to save power, which is the main justification for Optimus given by laptop manufacturers.



Hakaba said:


> Is that means we can not have accelerated graphics on the laptop screen (even with Windows) ?



Oh, Optimus works just fine with Windows.



Hakaba said:


> Without «Optimus», I can not have hdmi+laptop screen ?



You can start two separate Xorg servers, configured to use Intel and Nvidia GPUs respectively.


----------



## Hakaba (Dec 31, 2019)

I just installed the intel driver (i915kms) and now I have a laptop with integrated screen, but without HDMI.
I explore the two Xorg server way, but I am not sure that is what I want (may I move windows between screen ?)

First tests with two XOrg :
When I start a second X server, the first screen switch to black...
I have to logout from the second XFCE session to recover the first one (can not switch between session).

So I am not able to have two working screen at the same time now.


----------



## Hakaba (Jun 13, 2020)

More information here :

```
#xrandr -d :0 --listproviders
Providers: number : 1
Provider 0: id: 0x43 cap: 0xa, Sink Output, Sink Offload crtcs: 3 outputs: 1 associated providers: 0 name:modesetting

#xrandr -d :8 --listproviders
Providers: number : 1
Provider 0: id: 0x1b8 cap: 0x0 crtcs: 4 outputs: 3 associated providers: 0 name:NVIDIA-0
```

I try `xrandr --setprovideroutputsource NVIDIA-0 modesetting`


```
#xrandr -d :8 --setprovideroutputsource NVIDIA-0 modesetting
Could not find provider with name modesetting
#xrandr -d :0 --setprovideroutputsource NVIDIA-0 modesetting
Could not find provider with name NVIDIA-0
```

The main issue is that I have two "X Screen". How can I merge them ?


----------



## Mjölnir (Jun 14, 2020)

Hakaba said:


> [...] The main issue is that I have two "X Screen". How can I merge them ?


??? IMHO you do _not_ have two _"X Screens"_. What XRANDR does is merging all monitors into one _screen_ -- unlike XINERAMA, but you don't want that (it has nasty limitations).
You combine the monitors in a server-layout.conf in /usr/local/etc/X11/xorg.conf.d


----------



## Hakaba (Jun 14, 2020)

In the xrandr man, DISPLAY (option -d) is for select «X Screen».
I need to have display :0.0 and :0.1instead of :0.0 and :8.0.



> -d, --display name
> This option selects the X display to use. Note this refers to
> the X screen abstraction, not the monitor (or output).



I have a strange :0.1 sometimes with the name «default» and the max res x720.
But I did not find where is display this output.

I have two Xorg server here :

```
# ps aux | grep X
root       1333    0,0  0,1 25269372   44304 v0- S    03:10      1:10,35 /usr/local/bin/Xorg -sharevts -novtswitch -noreset -config /var/cache/nvidia-headless/xorg.conf -configdir xorg-nvidia-headless.conf.d :8
root       1813    0,0  0,4   212236  120028 v0  S    03:47      2:10,32 /usr/local/bin/Xorg :0 -auth /home/hakaba/.serverauth.1799
```


----------



## Mjölnir (Jun 14, 2020)

> [...]
> I have a strange :0.1 sometimes with the name «default» and the max res x720.
> But I did not find where is display this output.
> I have two Xorg server here :
> ...


OK, you have two Xservers.  So you _do_ have two _screens_ because obviously each Xserver has it's own and 8 is the default shift. The _headless_ Xserver on ":8" obviously is not connected to any monitor, that's what _headless_ is...
What you want is

One Xserver
Two drivers -- one for each GPU you have: intel(4) from x11-drivers/xf86-video-intel and nvidia (you seem to already have the last one)
this depends on which _heads_ you want to use, and to which GPU they connect.  I assume your internal monitor is connected to the Intel HD onchip-GPU, and not all external heads are connected to the extra nvidia card.
Three (? as many as you have _heads_, i.e. graphics card output plugs) _monitors_
_make shure you have the right KMS drivers (from ports, not base):_ `pkg info drm-kmod` 
To get where you want, it's advantageous to have at least these three config files in /usr/local/etc/X11/xorg.conf.d:

server-layout.conf
intel.conf and
nvidia.conf
and I strongly suggest also monitors.conf
Download from my previous post for an example. They are not large, you can read through them in <5 minutes.
Unfortunately, the server-layout.conf suggests you have more than one _screen_.  _But XRANDR (which is enabled by default) merges all into one._
Thus :0.1 refers to the 2nd monitor.  Look into your Xorg.0.log and/or ourput of `xrandr --listmonitors` or just plain `xrandr`


----------



## Mjölnir (Jun 14, 2020)

You must connect

monitor0<->driver0 = _screen0_ in intel.conf and monitor.conf
monitor1<->driver1 = _screen1_ in nvidia.conf and monitor.conf
if you want to use a _head_ that is connected to the nvidia card, else like 1.
connect these _screens_ in server-layout.conf
Then RandR puts that together automagically.  Like I mentioned before, unfortunately RandR let's us assume we have two _screens_, but it merges them.  Eventually that's exactly what you want... and not a _headless_ Xserver...


----------



## Mjölnir (Jun 14, 2020)

shkhln said:


> [...] You can start two separate Xorg servers, configured to use Intel and Nvidia GPUs respectively.


Why do you send him this way???  That's the XINERAMA way, and probably not what he wants.
Hakaba, you have to get rid of the headless Xserver.


----------



## Hakaba (Jun 14, 2020)

Thanks a lot.
I will try all this things tomorrow.

I have the good drm-kmod driver (I already test that). I stop the headless part and comment `#nvidia_xorg_enable="YES"` in rc.conf.


----------



## shkhln (Jun 14, 2020)

mjollnir said:


> Why do you send him this way???



Are you familiar with Bumblebee? OP is obviously using something derived from https://reviews.freebsd.org/D22521. (Which is, for the record, a different solution from my suggestion above. I didn't say anything about headless X servers.)


----------



## Mjölnir (Jun 15, 2020)

shkhln said:


> Are you familiar with Bumblebee?


No


shkhln said:


> OP is obviously using something derived from https://reviews.freebsd.org/D22521. (Which is, for the record, a different solution from my suggestion above. I didn't say anything about headless X servers.)


OK.

1st please be ashured I did not want to offend anyone.  You tried to help, that's what counts.
2nd, IMHO a Xserver can handle two drivers.  Do you agree?


----------



## shkhln (Jun 15, 2020)

I just dropped a ServerLayout section in my config and, of course, Xorg completely ignored it. In any case, even if you manage to make it work, without libglvnd you will not be able to use OpenGL on both screens.


----------



## Hakaba (Jun 15, 2020)

I try a lot of things since the end of 2019. I have installed the nvidia-headless driver to have a working `optirun`.

Now I test the solution with monitors.
But I only have one provider with `xrandr --listproviders` command.

I can have the Intel or the NVidia one (depending of my config) but never both appear.
I have a "leftOf" screen as my mouse can go out of my laptop screen. But the HDMI screen stay black.
I will spend more time in this concern this WE


----------



## Mjölnir (Jun 15, 2020)

I have a dual-monitor setup with intel.  So that should be no problem if you adjust my config examples to fit your needs (the monitors.conf) -- this works only if some head is connected or routed to the intel card.   Maybe that is possible in the BIOS?  If the intel card only connects to the internal laptop screen, this wil not work.  But then you do not use the nvidia card, which is ok for office use, even some games will run run fast enough.  For the specials concerning your nvidia card, shkhin is the better one to listen to.  I have no nvidia card.


----------



## Hakaba (Jun 16, 2020)

My laptop can not use the Intel card to display external monitor, neither the Nvidia card to display internal.
I ask in MSI forums and if I did not have physical switch, it is not possible.
I also search in advanced BIOS, but as I do not know how this config can be named, I found nothing relevant.

Back to the solution with two Xorg server (maybe in a jail and x2x to display both in the same time ?)

about Blumblebee, is that working in FreeBSD ?


----------



## Mjölnir (Jun 16, 2020)

IMHO two Xservers is going to be a XINERAMA solution, which was superseeded by XRANDR. XINERAMA has odd flaws, e.g. it hides physical entities of the monitor (phys. dimension & resolution, DPI) from the apps.  XRANDR is more modern and was written with what was learned from XINERAMA.
I am shure I have read somewhere that one Xserver can handle two (or more) GPU drivers; that would mean you can go a XRANDR solution.


----------



## Hakaba (Jun 16, 2020)

Ok, I will test all kind of things this weekend.
If I found a way, I will post the solution here.


----------



## shkhln (Jun 17, 2020)

mjollnir said:


> I am sure I have read somewhere that one Xserver can handle two (or more) GPU drivers; that would mean you can go a XRANDR solution.



Ahem,

```
% cat /var/log/Xorg.0.log | grep VGA
[   301.567] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
```

I don't know if there is any kind of alternative multi-(card|driver|GPU) support. Nothing is certain with Xorg.


----------



## Mjölnir (Jun 17, 2020)

shkhln said:


> ```
> % cat /var/log/Xorg.0.log | grep VGA
> [   301.567] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
> ```


This is the point of interest! I tried to add the sddm(1) user to the _video_ group, that did not help.  There _must_ be a way to achieve that.


shkhln said:


> I don't know if there is any kind of alternative multi-(card|driver|GPU) support. Nothing is certain with Xorg.


RTFM xorg.conf(5) says: _"The config file may have multiple Device sections.  There must be at least one, for the video card being used."_


----------

