# Information collection thread: Graphics drivers, xorg.conf etc.



## Snurg (Feb 23, 2021)

I am going to write an installer for setting up xorg and graphics drivers.
As I currently only have computers with Nvidia graphics, I need information how other graphics chips are set up, in particular Intel and ATI/AMD.
In case anybody is willing to help me, I would be grateful if you can post the following information of your working configuration:

`pciconf -lv | grep -A4 vgapci`
needed are the lines containing the vgapci devices:

```
vgapci0@pci0:15:0:0:    class=0x030000 card=0x084a10de chip=0x0dd810de rev=0xa1 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device = 'GF106GL [Quadro 2000]'
    class = display
    subclass = VGA
```

relevant parts of...
...loader.conf

```
kern.vty="sc"
nvidia_load="YES"
nvidia_name="nvidia"
nvidia_modeset_load="YES"
nvidia_modeset_name="nvidia-modeset"
linux_load="YES"
module_blacklist="vt vesa"
```

relevant parts of...
...rc.conf

```
linux_enable="YES"
```

if possible, your full
...xorg.conf

```
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 390.138  (buildmeister@swio-display-x64-rhel04-03)  Thu May 14 04:05:40 PDT 2020

Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/sysmouse"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "keyboard"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "Unknown"
HorizSync 28.0 - 33.0
VertRefresh 43.0 - 72.0
Option "DPMS"
EndSection

Section "Device"
Identifier "Device0"
Driver "nvidia"


    VendorName     "NVIDIA Corporation"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
EndSubSection
EndSection
```

Thank you very much!


----------



## eternal_noob (Feb 23, 2021)

Snurg said:


> pciconf -lv


A better command is `pciconf -lv | grep -B3 display`. Much less output to search.


Snurg said:


> linux_enable="YES"


Why is enabling the linuxulator relevant for Xorg?


Snurg said:


> if possible, your full
> ...xorg.conf


The usage of xorg.conf is discouraged, the autodetection of Xorg works almost flawless these days.


> Video cards, monitors, and input devices are      automatically detected and do not require any manual      configuration.  Do not create xorg.conf      or run a -configure step unless automatic      configuration fails











						Chapter 5. The X Window System
					

This chapter describes how to install and configure Xorg on FreeBSD, which provides the open source X Window System used to provide a graphical environment




					docs.freebsd.org
				




On topic:

I use (a rather ancient) Intel card:

```
[xx@xx ~]$ pciconf -lv | grep -B3 display
vgapci0@pci0:0:2:0:    class=0x030000 card=0x3048103c chip=0x2e128086 rev=0x03 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '4 Series Chipset Integrated Graphics Controller'
    class      = display
--
vgapci1@pci0:0:2:1:    class=0x038000 card=0x3048103c chip=0x2e138086 rev=0x03 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = '4 Series Chipset Integrated Graphics Controller'
    class      = display
```
Relevant entry in /etc/rc.conf:

```
kld_list="/boot/modules/i915kms.ko"
```

/boot/loader.conf

```
kern.vty=vt
```

No Xorg config files.


----------



## Snurg (Feb 23, 2021)

*Good suggestion with the grep! Thanks *

Regarding your remarks to...
...linux_enable:
This comes from the nvidia driver (linux binary).
...xorg.conf
It is relevant, in case there is any with Device section regarding the graphics driver.
My plan is to supply a working xorg.conf for all configurations.
It does no damage, and in case it turns out one needs to configure something, it is always convenient when a xorg.conf is already in place.


----------



## SirDice (Feb 23, 2021)

Snurg said:


> This comes from the nvidia driver (linux binary).


Sigh, this incorrect information just seems to continue to propagate. The Linux option of the NVidia driver is for providing support for the Linux compatibility layer so you can use the driver with Linux applications. It is NOT required for the driver to work. And you don't need to load it, if the NVidia driver has been built with Linux support it will be automatically loaded, there's no need to do this yourself.


Snurg said:


> ```
> nvidia_load="YES"
> nvidia_name="nvidia"
> nvidia_modeset_load="YES"
> ...


All wrong. Use `kld_list="nvidia"` or `kld_list="nvidia-modeset"` (depends on the card and driver version). 




freebsd_noob said:


> /boot/loader.conf
> 
> ```
> kern.vty=vt
> ```


This is the default, no need to explicitly set it.


----------



## hruodr (Feb 23, 2021)

```
# pciconf -lv | grep -B3 display
vgapci0@pci0:0:1:0:     class=0x030000 card=0x84a51043 chip=0x98021002 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Wrestler [Radeon HD 6310]'
    class      = display
```

All out of the box, nothing in loader.conf, xorg.conf or rc.conf, but I had to install:


```
# pkg info | grep video
xf86-video-ati-19.1.0_3,1      X.Org ati display driver
xf86-video-scfb-0.0.5_2        X.Org syscons display driver
xf86-video-vesa-2.5.0          X.Org vesa display driver
```


----------



## Snurg (Feb 23, 2021)

SirDice said:


> Sigh, this incorrect information just seems to continue to propagate. The Linux option of the NVidia driver is for providing support for the Linux compatibility layer so you can use the driver with Linux applications. It is NOT required for the driver to work. And you don't need to load it, if the NVidia driver has been built with Linux support it will be automatically loaded, there's no need to do this yourself.


Thank you for clarifying this!
I guess it won't do damage having the Linux emulation active in case any app wants it.



SirDice said:


> All wrong. Use `kld_list="nvidia"` or `kld_list="nvidia-modeset"` (depends on the card and driver version).


My installer will grab and use _the most recent driver_ from the nvidia website available for a particular chipset, which is atm 390.141 for newer cards.
The configuration is done via nvidia-xconfig, so the configuration is exactly the way Nvidia recommends.
_These are configured differently_ than the old packaged 304 and 340 drivers, which my installer will _not_ use, as the current drivers are more reliable.
For legacy cards, the latest according drivers will be downloaded and installed from the Nvidia driver site, i.e. 367, 340, 304, 173, 96 or 71.


----------



## SirDice (Feb 23, 2021)

Snurg said:


> My installer will grab and use _the most recent driver_ from the nvidia website available


Don't. Use the port, x11/nvidia-driver. The reason is that the NVidia driver install _replaces_ a couple of Xorg libraries. The port takes care of this, the nvidia installer doesn't. There's no reason to use the driver from the NVidia website, the port is kept reasonably up to date. And this also registers correctly with the package database. Anything you install outside of this won't be registered.



Snurg said:


> which is atm 390.141 for newer cards.


It's 460.39, which is also the version that's available as a port/package. 390 is a legacy version, x11/nvidia-driver-390.



Snurg said:


> The configuration is done via nvidia-xconfig, so the configuration is exactly the way Nvidia recommends.


It's not. It's just a tool that generates an old school xorg.conf, which you don't need any more. NVidia doesn't recommend anything in this regard.


----------



## Snurg (Feb 23, 2021)

SirDice said:


> Don't. Use the port, x11/nvidia-driver. The reason is that the NVidia driver install _replaces_ a couple of Xorg libraries. The port takes care of this, the nvidia installer doesn't.


Mhh that is interesting!
Sounds like that this could result in update breakages. Need to look into that, which libs get replaced.
For my the reason not to use the packaged drivers is the higher (i.e. 100%) reliability of the current "original nvidia" drivers regarding suspend/resume.

Okay, I will add an option to use the packaged driver if the installed card is supported by it, in case people prefer to use that.


----------



## eternal_noob (Feb 23, 2021)

Snurg said:


> Okay, I will add an option to use the packaged driver if the installed card is supported by it, in case people prefer to use that.


This option should be enabled by default. Because


> And this also registers correctly with the package database. Anything you install outside of this won't be registered.



I don't want to run down your effort to write an automated installer but:

Installing packages outside the package database in counterproductive.

You say that it is "tedious, time-consuming and not at all rewarding to manually fill out the gap between bsdinstall and having a working desktop system."
I disagree. It's fun, easy and rewarding because you learn something. And you do it once and then never again.

I quote Trihexagonal


> But I don't see it as a tedious task. I see it as a labor of love, ability and individualism to get my own ground-up custom built FreeBSD desktop complied by me from source and like no other you see in any screenshot.



The work to keep this installer up-to-date and working with all sorts of graphic cards will be enormous.

I think a better approach would be to just point people to https://docs.freebsd.org/en/books/handbook/x11/
The handbook is excellent and it's there for a reason.


----------



## Snurg (Feb 23, 2021)

freebsd_noob said:


> It's fun, easy and rewarding because you learn something. And you do it once and then never again.


I have done it too often, and I find it more rewarding to write an installer than doing that manually again 



freebsd_noob said:


> The work to keep this installer up-to-date and working with all sorts of graphic cards will be enormous.


80% of the work is needed for Nvidia, i915 and amdgpu do not need much work.


----------



## zirias@ (Feb 23, 2021)

Hm, in general, setting up a FreeBSD desktop consists of two things:

* Configure the base system to be more suitable for a desktop (some sysctls, some devfs rules and config, ...)
* Install packages

I don't think that's all too tedious, but automating it *might* be useful for some users. Anyways, I agree, such an installer should *never* circumvent the package database by default.

If on your system, the upstream nvidia driver works somehow "better", that's an edge-case, and sure, your installer *might* offer to use it, but should add a big fat warning about the consequences.

There could be other edge cases no installer could ever handle, like e.g. on my 12.2 desktop with an aging AMD APU, I need to use drm-fbsd11.2-kmod, because the version in -fbsd12.0- contains a bug (obviously from upstream Linux) hitting exactly my graphics chip. IMHO no way to handle *such* things in an installer.


----------



## shkhln (Feb 23, 2021)

SirDice said:


> Don't. Use the port, x11/nvidia-driver.


Seconded. If you don't like specific applied patches, fork the port and throw them out.



Zirias said:


> If on your system, the upstream nvidia driver works somehow "better", that's an edge-case, and sure, your installer *might* offer to use it, but should add a big fat warning about the consequences.


It certainly isn't. Linux compat is entirely broken out the box, for example.


----------



## zirias@ (Feb 23, 2021)

shkhln said:


> Linux compat is entirely broken out the box, for example.


You mean in the port? Then it must be fixed there…


----------



## Beastie7 (Feb 23, 2021)

I would like make something that probes, sets up, and configuration all hardware/ACPI interfaces. This could also be an API that KDE recognizes and can give me a damn power off button, or brightness change indicators. Like a SMIT-like or ncurses version Windows device driver manager or something.. I need the system to *tell *me what doesn't work, and what does work. What's supported and what isn't. Having to sift through sysctls, kmods, tuning rc.conf/loader.conf, etc, is very tedious and frustrating. CLI desktop administration is fine, but fscking around with hardware is not worth my time; it gives me Windows XP nightmares. Especially when the system doesn't even save my ACPI settings that I set for brightness, etc. I was on the verge of giving up the other day. Adopting OpenRC would fix a lot of this.


----------



## shkhln (Feb 23, 2021)

Zirias said:


> You mean in the port? Then it must be fixed there…


No, the other way around.


----------



## hruodr (Feb 23, 2021)

Snurg said:


> For my the reason not to use the packaged drivers is the higher (i.e. 100%) reliability of the current "original nvidia" drivers regarding suspend/resume.


I think, packaged by default, other optional with warning, is the better solution for people that 
want transparency, do not want to spend much time understanding the system, configuring 
and troubleshooting if something did not work.

I agree with you, one has other things to do than configure and administer the system, one wants to
do his work with the computer. For that reason I like the package system, although I do compile some
software.


----------



## Snurg (Feb 23, 2021)

Beastie7 said:


> I need the system to *tell *me what doesn't work, and what does work. What's supported and what isn't. Having to sift through sysctls, kmods, tuning rc.conf/loader.conf, etc, is very tedious and frustrating. CLI desktop administration is fine, but fscking around with hardware is not worth my time


Exactly.
What I already have implemented is a postinstaller that installs and boots up a webserver running a CGI as root, to do all that crap interactively, and nicely presented, with more than 80x24 screen space.
Either using a browser on another computer (especially when no GUI gets installed on that particular computer), or on the computer itself, be it using lynx _or a graphical browser on top of X_. This is the part I will add next.


----------



## eternal_noob (Feb 23, 2021)

Snurg said:


> a postinstaller that installs and boots up a webserver running a CGI as root, to do all that crap interactively.


Why not a simple  shell script or ncurses application? Installing a webserver and use lynx in order to configure X is a bit... overkill.


----------



## Snurg (Feb 23, 2021)

freebsd_noob said:


> Why not a simple  shell script or ncurses application? Installing a webserver in order to configure X is a bit... overkill.


Hehe no. This is only the beginning, the real purpose is to provide a basis to easily do all this fine tuning (sysctl, dev, rc.conf etc) so no step gets forgotten, and administer things like network, pf and jails in an easy way, without need for CLI.
Just a toolbox that the community can use and contribute to.

Edit: I use [PMAN=]dialog[/PMAN] for the basic setup. The more complex things are easier done with HTML, lynx is only needed if you want to locally set up/configure a non-GUI computer without using anothers' computers' browser.


----------



## zirias@ (Feb 23, 2021)

shkhln said:


> No, the other way around.


Then you misinterpreted what I meant with "upstream"  But nevermind!


----------



## shkhln (Feb 23, 2021)

Zirias said:


> Then you misinterpreted what I meant with "upstream"  But nevermind!


I'm assuming upstream = Nvidia. My reply is entirely consistent with this assumption.


----------



## zirias@ (Feb 23, 2021)

Well, no. But I won't continue arguing about the semantics of the english language…


----------



## shkhln (Feb 23, 2021)

Besides "it" being inherently ambiguous I _really_ don't see anything wrong with that sentence. You act like it's obvious, but it's not.


----------



## hruodr (Feb 23, 2021)

Snurg said:


> What I already have implemented is a postinstaller that installs and boots up a webserver running a CGI as root,


If you use a language like tcl for your project, you may perhaps write a small, special purpose
http-server (not even cgi necessary). Perhaps only few lines.

You can see examples to begin with here:






						The Smallest Tcl Web Server
					

Tclers wiki




					wiki.tcl-lang.org
				




The difficult thing to write is the http client, not the server, specially if the purpose is very restricted.
And here you see a description of the protocoll:






						HTTP Made Really Easy
					

Tutorial:  Quickly learn how to use HTTP in your network          applications, if you know basic sockets programming.  Covers          HTTP 1.0 and HTTP 1.1.  Includes sample clients in Perl.



					www.jmarshall.com


----------



## Snurg (Feb 23, 2021)

Didn't know one can use even Tcl for web serving...
I am used to Perl, it is powerful like shell and easy like BASIC.
CGI script size is heavy. The integrated web based jail manager alone is a few thousand lines.


----------



## eternal_noob (Feb 23, 2021)

Snurg said:


> the real purpose is to provide a basis to easily do all this fine tuning (sysctl, dev, rc.conf etc) so no step gets forgotten, and administer things like network, pf and jails in an easy way, without need for CLI.


Reminds me of sysutils/desktop-installer:


> Desktop-installer is a post-install script that embodies the extensive knowledge needed to configure a clean, reliable FreeBSD desktop system. It automates the process of configuring a FreeBSD workstation or laptop computer, allowing typical users to set up a fully functional desktop environment in less than an hour.





			Acadix Home


----------



## hruodr (Feb 23, 2021)

Snurg said:


> Didn't know one can use even Tcl for web serving...



The important part: tcl's socket and wait commands. The rest is simple because http is simple. The 
difficult part is rendering html/css, running javascript, etc, but that is done by the client, not the server.
You do not need to implement cgi, as you see in the examples, you can run other things than puts
(write to stdout). And I find tcl easier than perl.


----------



## SlySven (Feb 23, 2021)

I am using the FreeBSD port of the NVidia drivers and seem to have to use the (FreeBSD branded!) NVidia configuration tool to set up my displays the way I like it (this seems to involves inserting a NVidia custom line into the xorg.conf file - when one clicks the save to Xorg.conf option and which does, obviously required permissions if not root and one wants to write to the system one) in order to get all (three) screens to show the greeter before login.

However, I believe that afterwards there is a separate, per-user dot-file used to save the details (when one clicks the "Apply" button) - but the two are definitely separate actions. So, doing without the Xorg.conf file might indeed be what one ought to be doing...


----------



## JAW (Feb 23, 2021)

Snurg said:


> `pciconf -lv | grep -A4 vgapci`
> 
> ```
> vgapci0@pci0:0:2:0:     class=0x030000 card=0x011b106b chip=0x16268086 rev=0x09 hdr=0x00
> ...


----------



## mickey (Feb 23, 2021)

`pciconf -lv | grep -A4 vgapci`

```
vgapci0@pci0:0:2:0:     class=0x030000 card=0x86941043 chip=0x19128086 rev=0x06 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'HD Graphics 530'
    class      = display
    subclass   = VGA
```

rc.conf

```
kld_list="/boot/modules/i915kms.ko"
```

xorg.conf

```
# Set up additional font paths.

Section "Files"
        FontPath                "/usr/local/share/fonts/terminus-font"
        FontPath                "/usr/local/share/fonts/urwfonts"
        FontPath                "/usr/local/share/fonts/dejavu"
        FontPath                "/usr/local/share/fonts/webfonts/"
EndSection

# X server settings.

Section "ServerFlags"
        Option                  "BlankTime"     "10"
        Option                  "StandbyTime"   "23"
        Option                  "SuspendTime"   "23"
        Option                  "OffTime"       "23"
EndSection

# Assume some sane defaults for all keyboards.

Section "InputClass"
        Identifier              "Keyboard Defaults"
        MatchIsKeyboard         "yes"
        Option                  "XkbLayout"     "de"
        Option                  "XkbVariant"    "nodeadkeys"
        Option                  "XkbOptions"    "numpad:pc,kpdl:dot"
EndSection

# PS/2 system keyboard is a 102-key model.

Section "InputClass"
        Identifier              "PS/2 System Keyboard"
        MatchIsKeyboard         "yes"
        MatchProduct            "AT keyboard"
        Option                  "XkbModel"      "pc102"
EndSection

# Assume some sane defaults for all pointing devices.

Section "InputClass"
        Identifier              "Mouse Defaults"
        MatchIsPointer          "yes"
#       Option                  "Buttons"               "3"
        Option                  "MiddleEmulation"       "no"
EndSection

# Graphics card configuration.

Section "Device"
        Identifier              "HD530"
        Driver                  "modesetting"
        VendorName              "Intel"
        BoardName               "HD 530"
EndSection

# Monitor configuration.

Section "Monitor"
        Identifier              "PLE2472HD"
EndSection

# Screen configuration.

Section "Screen"
        Identifier              "Screen0"
        Device                  "HD530"
        Monitor                 "PLE2472HD"
        DefaultDepth            24

        SubSection "Display"
                Depth           24
        EndSubSection
EndSection
```
sysctl.conf

```
# Configure kernel evdev support:
# 0x01  Enable sysmouse
# 0x02  Enable kbdmux
# 0x04  Enable hardware mouse devices
# 0x08  Enable hardware keyboard devices
kern.evdev.rcpt_mask=0xC
```


----------



## richardtoohey2 (Feb 23, 2021)

Snurg said:


> I guess it won't do damage having the Linux emulation active in case any app wants it.


Are there any security implications in doing that?  I don't know, just wondering.  Might not be important in the context of a desktop set-up (lots of other things being installed and enabled, so one more thing won't really make a difference).


----------



## SlySven (Feb 23, 2021)

Ah, back in FreeBSD land and I tried removing /etc/X11/xorg.conf and it didn't work - looking through /var/log/Xorg.0.log I see that it tried to load the *nv* module (and left me with a set of blank screens) instead of the *nvidia* one that was used when I put the file back and got the _sddm_ greeter back.


----------



## Mjölnir (Feb 24, 2021)

Snurg said:


> I am going to write an installer for setting up xorg and graphics drivers.


I would suggest to call it sysutils/autoSnurg 


Snurg said:


> As I currently only have computers with Nvidia graphics, I need information how other graphics chips are set up, in particular Intel and ATI/AMD.
> In case anybody is willing to help me, I would be grateful if you can post the following information of your working configuration: `pciconf -lv | grep -A4 vgapci`


`psearch -c sysutils hardware` Oh, looks interesting: `portell hw-probe`

```
The tool is intended to simplify collecting of logs necessary for investigating hardware related problems. [...]
WWW: https://bsd-hardware.info/
```
You might wanto to ask the maintainer of that site to provide you with tons of `vgapci` device snippets.  In the meantime...
`pciconf -lv | fgrep -A1 -B3 display`

```
vgapci0@pci0:0:2:0:     class=0x030000 card=0x503617aa chip=0x16168086 rev=0x09 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'HD Graphics 5500'
    class      = display
    subclass   = VGA
```
/boot/loader.conf

```
# System tunables/sysctl(8) knobs.  Please keep sorted to avoid duplicates.
#
# INTEL DRM WITH graphics/drm-kmod PACKAGE (NEW)
compat.linuxkpi.enable_rc6="7"  # ENABLE POWER SAVING RENDER C-STATE 6
compat.linuxkpi.enable_dc="2"   # ENABLE POWER SAVING DISPLAY C-STATES
compat.linuxkpi.enable_fbc="1"  # ENABLE FRAME BUFFER COMPRESSION FOR POWER SAVINGS
compat.linuxkpi.i915_fastboot="1" # SKIP UNNECESSARY MODE SETS AT BOOT TIME
compat.linuxkpi.i915_nuclear_pageflip="1"
compat.linuxkpi.semaphores="1"  # USE SEMAPHORES FOR INTER RING SYNC
```
/etc/rc.conf

```
kld_list="/boot/modules/i915kms.ko ${kld_list} dpms"
kld_list="$kld_list sem"                # for firefox?
dbus_enable="YES"
hald_enable="YES"                       # obsolete, still webcamd(8) needs it
linux_enable="YES"                      # some KDE apps need that?
linux_mounts_enable="NO"          # want tmpfs(5) mount option size=XY for /compat/linux/tmp in fstab(5)
sddm_enable="YES"                     # sddm(1) graphical login & sddm-greeter(1)
sddm_nice="0"                              # because we have priority=-5 for root in login.conf(5)
webcamd_enable="YES"
webcamd_flags="-H"
kld_list="${kld_list} cuse"             # cuse(4) for webcamd(8)
```
/etc/sysctl.conf

```
# nothing related to graphics adapter
```
/usr/local/etc/X11/xorg.conf.d/{monitors,server-layout,video}.conf

```
#
# The Xserver(8) recognizes the dimensions of the monitor correctly, but
# later the intel(5) driver sets them to much larger values.  I guess this
# is considered a feature, intended to shrink the output on very small
# screens like subnotebooks/tablets/phones. NOTE this sizing stuff is
# slightly complex (pixel size, distance eye-display, etc...).
# Pro:
#       + for the GUI it appears like a larger monitor, and more items can be
#         placed on the sceen -- this improves the usability of these devices.
#       + for developers it's much simpler to agree on a standard resolution
#         (nowadays 96 DPI), and write their programs just for that.
#         Then the requirements of different use-cases are done by scaling.
# Contra:
#       - the server lies (intentionally) about the DPI, thus all the fonts are
#         shrinked and often difficult to read, esp. when browsing the internet.
#
# While this may make sense on a smartphone/tablet, I want "the truth" on
# my 14" laptop.
#
# The key is to link the monitor to the card in the device section of the
# graphics card: e.g. in /usr/local/etc/X11/xorg.conf.d/intel-HD-5500.conf
# Option "Monitor-LVDS1"        "<Notebook internal LCD>" or
# Option "Monitor-eDP1"         "<Notebook internal TFT>"
# Option "Monitor-DP2"          "<external monitor (needs setup)>"
# NOTE: beware, naturally in a docking station the numbering changes:
# Option "Monitor-DP2-3"        "<external LCD [VGA,docked]>"
#
Section "Monitor"
    Identifier          "<default monitor>"
    #these two should be enabled if DisplaySize is set below
    VendorName          "CMN"
    ModelName           "1482"
    Option              "primary"       "yes"
    # This monitor does not report power management features...
    #    Option             "DPMS"          "off"
    # You can grep(1) these values from /var/log/Xorg.0.log
    # Although the Xserver(8) detects it, we have to tell intel(5) explicitely
    # to use this and not setting the wrong DPI.
    DisplaySize         309     174     # also in Xorg.0.log
EndSection
Section "Monitor"
    Identifier          "<external LCD [Philips]>"
    # If you coment out the next two lines, this will match any monitor...
    VendorName          "PHL"           # Philips
    ModelName           "81d"           # Philips 170b
    # tell the GPU driver to use this and do not set the wrong DPI.
    DisplaySize         338     270     # grep(1) from Xorg.0.log: "Image size"
    Option              "PreferedMode"  "1280x1024"
    # For multihead-setup:
    Option              "primary"       "no"
    Option              "LeftOf"        "<default monitor>"
EndSection
Section "Monitor"
    Identifier          "<external monitor (needs setup)>"
    #Option             "Ignore"        "yes"
    Option              "primary"       "no"
    Option              "leftOf"        "<default monitor>"
    # tell the GPU driver to use this and do not set the wrong DPI.
    #DisplaySize        horiz   vert    # TODO: grep(1) from Xorg.0.log: "Image size"
EndSection
Section "Screen"
    Identifier  "<default Screen>"
    Device      "<Intel HD Graphics 5500>"
    Monitor     "<default monitor>"
EndSection
Section "Screen"
    Identifier  "<external Screen [Philips]>"
    Device      "<Intel HD Graphics 5500>"
    Monitor     "<external LCD [Philips]>"
EndSection
Section "Screen"
    Identifier  "<external Screen [unknown]>"
    Device      "<Intel HD Graphics 5500>"
    Monitor     "<external monitor (needs setup)>"
EndSection
Section "ServerLayout"
    Identifier  "<Multi Screen Layout [Philips]>"
    Screen      0 "<default Screen>"
    Screen      1 "<external Screen [Philips]>" leftOf "<default Screen>"
EndSection
Section "ServerLayout"
    Identifier  "<Multi Screen Layout [unknown]>"
    Screen      0 "<default Screen>"
    Screen      1 "<external Screen [unknown]>" leftOf "<default Screen>"
EndSection
Section "ServerLayout"
Identifier  "<Default Screen Layout [solo]>"
Screen      "<default Screen>"
EndSection
#
# Here we switch between layouts -- TODO: find out out to do that from sddm(8)
#
Section "ServerFlags"
#    Option     "DefaultServerLayout"   "<Default Screen Layout [solo]>"
    Option      "DefaultServerLayout"   "<Multi Screen Layout [Philips]>"
#    Option     "DefaultServerLayout"   "<Multi Screen Layout [unknown]>"
EndSection
Section "Module"
#    load "glamoregl"                                      # for Option "AccelMethod" "glarmor"
EndSection
Section "Device"
    Identifier  "<Intel HD Graphics 5500>"
    Driver      "intel"
    Option      "TripleBuffer"  "on"
    Option      "TearFree"      "on"
    Option      "UseEDIDDpi"    "yes"
#    Option     "AccelMethod"   "glamor"        # Default: UXA
# These are now in monitors.conf
    Option      "Monitor-eDP-1" "<default monitor>"
    Option      "Monitor-DP-1"  "<external monitor (needs setup)>"
    Option      "Monitor-DP-2"  "<external LCD [Philips]>"
    Option      "Monitor-HDMI-1" "<external LCD [Philips]>"
    Option      "Monitor-HDMI-2" "<external LCD [Philips]>"
EndSection
# RTFM xorg.conf(5) says: one "Device" section for each head.
# That's definitely bullshit! This fails:
#Section "Device"
#    Identifier "<Intel HD Graphics 5500 [Philips]>"
#    Driver     "intel"
#    Screen     1
#    Option     "TearFree"      "on"
#    Option     "Monitor-DP2-1" "<external LCD [Philips]>"
#EndSection
#Section "Device"
#    Identifier "<Intel HD Graphics 5500 [VGA,internal]>"
#    Driver     "intel"
#    Screen     2
#    Option     "TearFree"      "on"
#    Option     "Monitor-DP2"   "<external monitor (needs setup)>"
#EndSection
```
Thx to mickey, I'll add a keyboard.conf to the xorg.conf.d(5) folder.


----------



## SirDice (Feb 24, 2021)

SlySven said:


> Ah, back in FreeBSD land and I tried removing /etc/X11/xorg.conf and it didn't work - looking through /var/log/Xorg.0.log I see that it tried to load the *nv* module (and left me with a set of blank screens) instead of the *nvidia* one that was used when I put the file back and got the _sddm_ greeter back.


You only need a small file to fix that, /usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf:

```
Section "Device"
        Identifier "Card0"
        Driver     "nvidia"
EndSection
```


----------



## tyson (Feb 24, 2021)

Here is my setup. Output of `pciconf -lv | fgrep -A1 -B3 display` :

```
vgapci0@pci0:1:0:0:    class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1c02 subvendor=0x19da subdevice=0x2438
    vendor     = 'NVIDIA Corporation'
    device     = 'GP106 [GeForce GTX 1060 3GB]'
    class      = display
    subclass   = VGA
```
I have 2 monitors and im setting up keyboard layout for X too.
/usr/local/etc/X11/xorg.conf.d/10-nvidia.conf

```
ection "Device"
    Identifier     "NvidiaGFX"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GTX 1060 3GB"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "NvidiaGFX"
    Monitor        "DFP-6"
    DefaultDepth    24
#    Option         "Coolbits" "8"
    Option         "DPI" "94x94"
    Option         "UseEdidDpi" "False"
#    Option         "metamodes" "DFP-6: nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}, DFP-4: nvidia-auto-select +1920+432 {ForceFullCompositionPipeline=On}"
    Option         "MetaModes" "DFP-6: nvidia-auto-select +0+0 {ForceCompositionPipeline=On}, DFP-4: nvidia-auto-select +1920+432 {ForceCompositionPipeline=On}"
#    Option        "HardDPMS" "false"
#    Option         "AllowIndirectGLXProtocol" "off"
#    Option        "RenderAccel" "false"
    Option         "TripleBuffer" "on"
#    Option        "AllowUnofficialGLXProtocol" "True"
#    Option        "UseCompositeWrapper" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection
```
usr/local/etc/X11/xorg.conf.d/20-keyboard.conf:

```
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"    # Limit these settings to keyboards
        Driver "evdev"
        Option "XkbModel" "pc101"
        Option "XkbLayout" "pl"
        Option "XkbOptions" "lv3:ralt_switch"
EndSection
```
usr/local/etc/X11/xorg.conf.d/30-mouse.conf:

```
Section "InputClass"
        Identifier "Evdev Mouse"
        Driver "evdev"
        MatchProduct    "COMPANY USB Device"
        MatchIsPointer  "yes"
        #Option "evBits"  "+1-2"
        #Option "keyBits" "~272-287"
        #Option "relBits" "~0-2 ~6 ~8"
        #Option "Pass"   "3"
        MatchDevicePath  "/dev/input/event*"
EndSection
```
As u can see there is plenty of settings u can use evdev to configure.


----------



## Snurg (Feb 24, 2021)

Thank you all for your help!   

What is awesome is the usefulness of not only the data you provided, but also the many important side details!

For example, Mjölnir 's hint to https://bsd-hardware.info/ is a wonderful source to make sure one gets the detection right even for hardware nobody here has.

Or, for example, tyson showed that evdev() can still be used without hacking into the system.
This is very good! On Linux, re-enabling evdev fixes some of the problems libinput() causes in particular with scroll wheels and the like, and explicitly using evdev instad of libinput is way easier than to modify the sources to completely get rid of libinput.
So there will be an option to use evdev instead of libinput 

Ladies and gents, thank you all again


----------



## Deleted member 30996 (Feb 24, 2021)

I just added this to mine. No reason you can't use it if it will help your effort:

If you have a boxen with Switichable Graphics drivers for both chips should be checked to be installed at the Driver Selection screen. I have a Thinkpad T400 that has Switchable Graphics with Intel GMA 4500MHD and ATI Mobility Radeon HD 3470 chips. Both the Intel and ATI driver need to be checked for install at the driver selection screen during the install of x11/xorg.

Before you boot to the desktop it needs to be put into "Discreet" graphics mode in the BIOS. It then defaults to the Radeon chip and runs fine without any tweaking.


----------



## Snurg (Feb 24, 2021)

Trihexagonal said:


> If you have a boxen with Switichable Graphics drivers for both chips should be checked to be installed at the Driver Selection screen. [...] Both the Intel and ATI driver...
> 
> ... "Discreet" graphics mode in the BIOS. It then defaults to the Radeon chip and runs fine without any tweaking.


Thank you very much for this!  
The information regarding dual GPU notebooks is particularly important, to avoid user frustration, so I am particularly grateful for this information how to handle these combos correctly.

The information how to set up BIOS in these cases is crucial, too!
There will have to be big red info boxes alerting the user what must not be forgotten before proceeding!

So thanks to you the mystery of Intel/ATI combo is lifted 
Does anybody here have found out how to make other dual GPU combos like Intel/NvidiaOptimus etc work reliably, too?


----------



## fraxamo (Feb 24, 2021)

Snurg said:


> For example, Mjölnir 's hint to https://bsd-hardware.info/ is a wonderful source to make sure one gets the detection right even for hardware nobody here has.


You should also check out the NYC*BUG dmesgd site.


----------



## Deleted member 30996 (Feb 25, 2021)

Snurg said:


> Does anybody here have found out how to make other dual GPU combos like Intel/NvidiaOptimus etc work reliably, too?



I'm guessing but would think the process for all dual GPU combos would be the same procedure, select driver install for both chips, then set the BIOS to reflect the proper Graphics Mode. Most likely to "Discreet" Graphics. Some make need Linux base, others not.

This is what I have for making Nvidia work on older chips that aren't dual core and all I ever do to make it work. If it helps feel free to use it:

If your box uses an older nvidia chip, maybe a Quardo NVS 140M or Quadro 1000M with Optimus, we have easy work first. Your card will need x11/nvidia-driver-304 or x11/nvidia-driver-340, emulators/linux_base-c7, x11/nvidia-settings and x11/nvidia-xconfig.

As root, run `nvidia-xconfig`
Run `ee /ect/rc.conf`
Edit in `linux_enable="YES"`, save and exit.
Run `ee /boot/loader.conf`
To cover all chips, Edit in:


```
linux_load="YES"
nvidia_load="YES"
nvidia-modset_load="YES"
```
Now save file, exit editor and reboot.

Optimus still needs set to Discreet. After login run `startx`, the Nvidia splash screen will display briefly and it's "Straight On Till Desktop". (A Hammer film reference.)


----------



## astyle (May 7, 2021)

I would suggest first stringing all the command-line steps together and making sure they work correctly (Done in correct order, edit correct files, etc), and then just slap the GUI on top. Have a drop-down list of supported drivers, and a way to revert changes if you mess up.


----------



## Alain De Vos (May 7, 2021)

To have some nice colors on booting I use ,
loader.conf

```
kern.vt.color.0.rgb="#210021"
kern.vt.color.7.rgb="#ffff10"
kern.vt.color.15.rgb="#10ffff"
```

To have good performance with my radeon card,
xorg.conf

```
Section "Device"
    Identifier "Card0"
    Option "AccelMethod" "EXA"
    #Option "AccelMethod" "glamor"
    BusID "PC:1:0:0"
    Screen 0
EndSection
```

picom.conf

```
backend = "xrender";
```


----------



## monwarez (May 7, 2021)

Snurg said:


> ...
> Does anybody here have found out how to make other dual GPU combos like Intel/NvidiaOptimus etc work reliably, too?


See PR 192617
I use it daily since at least 1 or 2 years.

It can even work with linux emulation layers (For that you will just need to extract somewhere a linux version of VirtualGL,
and use it instead of the system one).

`pciconf -lv | grep -B3 display`


```
vgapci1@pci0:0:2:0:    class=0x030000 card=0x115b1462 chip=0x191b8086 rev=0x06 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'HD Graphics 530'
    class      = display
--
vgapci0@pci0:1:0:0:    class=0x030200 card=0x115b1462 chip=0x139b10de rev=0xa2 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'GM107M [GeForce GTX 960M]'
    class      = display
```

The only caveat is that I cannot run 32bit wine with my nvidia gpu. Using 64bit wine works with
the nvidia gpu.


----------



## grahamperrin@ (May 8, 2021)

Mjölnir said:


> … `portell` …



Rest in peace, misc/portell 0.2_1 and ports-mgmt/portell 0.2_2.

Instead, for example: 

`pkg rquery '%o %v %e' glx-utils lsblk`



eternal_noob said:


> … Reminds me of sysutils/desktop-installer: …



Also, partly, NomadBSD *initgfx*.

<https://github.com/nomadbsd/NomadBSD/blob/master/config/etc/rc.d/initgfx>


----------



## Alain De Vos (May 8, 2021)

glx-utils & mesa-demos both contain glxgears.


----------



## grahamperrin@ (May 8, 2021)

Alain De Vos said:


> glxgears



Also FYI graphics/drm_info, although I don't imagine its output being useful for this information collection exercise (I learnt of it through reading <https://lists.freebsd.org/pipermail/freebsd-current/2020-December/077724.html>).

Example output: <https://paste.nomagic.uk/?70912a26135b74d9#5ELC4t2NWfFBMdsUQp3hRBNpSCJPH6GtCBdu7EKW67p7>


----------



## grahamperrin@ (May 8, 2021)

Snurg said:


> relevant parts of...
> ...rc.conf




```
sddm_enable="YES"
kld_list="cuse fusefs usbhid drm"
```

– specifically `drm` *not* `radeonkms`



eternal_noob said:


> `pciconf -lv | grep -B3 display`




```
vgapci0@pci0:1:0:0:     class=0x030000 rev=0x00 hdr=0x00 vendor=0x1002 device=0x6841 subvendor=0x103c subdevice=0x17a9
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Thames [Radeon HD 7550M/7570M/7650M]'
    class      = display
```



Snurg said:


> relevant parts of...
> ...loader.conf



Maybe these two lines: 


```
cuse_load="YES"
vboxdrv_load="YES"
```

 – I should remove `cuse` from my `kld_list`.


----------

