FreeBSD with Onboard Intel and AMD Video Cards

This seems to come up a lot on the forums. It's fairly simple, and detailed on the wiki but on occasion, there seems to be some minor confusion, and a couple of things left out. People have different means of installing X, as well as their favorite programs. I use openbox and find that the following usually pulls in everything I need.
pkg install xorg-server rxvt-unicode openbox xf86-input-libinput xinit xauth

(There's lots of things I'm leaving out, but in theory, this should enable to you to startx with openbox and open a urxvt terminal). Don't install xf86-video-intel or vesa.

Assuming that you've installed X on FreeBSD, you very seldom need to the use xorg-configure. I'm not even sure if the handbook still recommends that. With onboard Intel or AMD cards, you do need the drm-kmod package.

One thing the wiki leaves out is that, due to some minor kernel incompatibilities, you have to build drm-kmod from ports. This, at time of writing, (January, 2021) is true for both 12.2 and CURRENT. And, to build this package from ports, you need to have the source tree installed. As most people know by now, FreeBSD has switched to git for updating source. So, if you don't have the source tree yet installed, you can use git. I cover this on my page, but for 12.2-RELEASE, or whatever the release of 12.x if you read this later on, the command, from /usr, is
git clone -b stable/12 --depth 1 https://git.freebsd.org/src.git src

When finished, you can, at time of writing, fetch ports with portsnap fetch extract, if you don't already have the ports tree installed. Once you have both the source and ports installed, you can build the drm-kmod by changing into the directory /usr/ports/graphics/drm-kmod and running make install clean.

Once this is done there is a package message telling you to add the following to /etc/rc.conf if it is an Intel driver.
kld_list="/boot/modules/i915kms.ko"

If using amd, the pkg message these days shows that you should add
kld_list="/boot/modules/amdgpu"

But I have found that at least sometimes, as the wiki says, I have to use amdgpu.ko, rather than just amdgpu. I've not really investigated it, and it's quite possible that both work.

You also need to be a member of the video group. With root privilege or sudo, run, assuming your user name is john
pw groupmod video -m john

It's easiest, after making the modifications, to just reboot.

On my yoga2, which has a high resolution screen, using the kmod-drm port makes fonts in console tiny to the point of being unreadable. So, on the advice of this article from lme.postach.io I add the following to /boot/loader.conf.
kern.vt.fb.default_mode="800x600

You can reboot and try startx at this point. If it worked, upon reboot, you should see the machine console font change to using framebuffer shortly after the boot begins.

This method lets me use FreeBSD on laptops with newer Intel and AMD cards. I have only tested it on the AMD T495 and the yoga2, where it's given me good performance. (for other issues with the yoga2 and FreeBSD, see my yoga2 page).