When will PRIME support be added to mhwd?

You can also do this. You just need to write a script :wink:

It is a very valid question though, very long overdue.

1 Like

for now we can use the bumblebee config:

# mhwd Driver Config

NAME="video-hybrid-intel-nvidia-bumblebee"
INFO="Hybrid bumblebee solution for NVIDIA Optimus Technology - Closed source NVIDIA driver & open source intel driver."
VERSION="2017.03.12"
FREEDRIVER="false"
PRIORITY="8"

# NVIDIA cards
CLASSIDS="0300 0302"
VENDORIDS="10de"
DEVICEIDS=">/var/lib/mhwd/ids/pci/nvidia.ids"

# Intel cards
CLASSIDS="0300"
VENDORIDS="8086"
DEVICEIDS="*"
BLACKLISTEDDEVICEIDS="0be1 8108"

# Conflicts with other mhwd configs
MHWDCONFLICTS="video-intel video-nvidia video-nvidia-304xx video-nvidia-340xx video-hybrid-intel-nvidia-340xx-bumblebee video-hybrid-intel-nouveau-bumblebee"

# Dependencies
DEPENDS="bumblebee nvidia-utils xf86-video-intel"
[[ -d /run/openrc ]] && DEPENDS="bumblebee-openrc nvidia-utils xf86-video-intel"
DEPENDS_64="lib32-primus lib32-nvidia-utils"
DEPKMOD="nvidia bbswitch"

XORGFILE="/etc/X11/mhwd.d/intel.conf"
BXORGFILE="/etc/bumblebee/xorg.conf.nvidia"
MODULESFILE="/etc/modprobe.d/mhwd-bbswitch.conf"
MODULESBLACKLIST="/etc/modprobe.d/mhwd-nvidia.conf"

make_bumblebee_xorg_config()
{
	MHWD_HEADING "${BXORGFILE}"

	echo 'Section "ServerLayout"' >> "${BXORGFILE}"
	echo '    Identifier "Layout0"' >> "${BXORGFILE}"
	echo '    Option "AutoAddDevices" "false"' >> "${BXORGFILE}"
	echo 'EndSection' >> "${BXORGFILE}"
	echo '' >> "${BXORGFILE}"

	MHWD_ADD_DEVICE_SECTION_FOR_EACH_BUSID "nvidia" "${BXORGFILE}" 10de "VendorName \"NVIDIA Corporation\"|Option \"NoLogo\" \"true\"|Option \"UseEDID\" \"false\"|Option \"ConnectedMonitor\" \"DFP\""
}

post_install()
{
	# Create intel xorg configuration with enabled sna acceleration method
	MHWD_HEADING "${XORGFILE}"
	MHWD_ADD_DEVICE_SECTION_FOR_EACH_BUSID "intel" "${XORGFILE}" 8086 "Option      \"AccelMethod\" \"sna\""
	MHWD_ADD_DRI "${XORGFILE}"
	MHWD_ADD_COMPOSITING "${XORGFILE}"
	MHWD_ADD_BACKSPACE "${XORGFILE}"

	# Create nvidia bumblebee xorg configuration
	make_bumblebee_xorg_config

	MHWD_HEADING "${MODULESFILE}"
	echo "options bbswitch load_state=0 unload_state=0" >> "${MODULESFILE}"


	MHWD_HEADING "${MODULESBLACKLIST}"
	echo "blacklist nouveau" >> "${MODULESBLACKLIST}"
	echo "blacklist nvidia" >> "${MODULESBLACKLIST}"
	echo "blacklist nvidia-modeset" >> "${MODULESBLACKLIST}"
	echo "blacklist nvidia-uvm" >> "${MODULESBLACKLIST}"
	echo "blacklist ttm" >> "${MODULESBLACKLIST}"
	echo "blacklist drm_kms_helper" >> "${MODULESBLACKLIST}"
	echo "blacklist drm" >> "${MODULESBLACKLIST}"

	# Unload modules if X is not running
	if [ ! "$(pgrep X)" ];	then
		rmmod -f nouveau
		rmmod -f nvidia
		rmmod -f nvidia-modeset
		rmmod -f nvidia-uvm
		rmmod -f ttm
		rmmod -f drm_kms_helper
		rmmod -f drm
	fi

	modprobe bbswitch

	set_bumblebee_driver "nvidia"

	mhwd-gpu --setxorg "${XORGFILE}"

	if [[ -d /run/openrc ]];then
		rc-update add bumblebee default
		rc-service bumblebee start
	else
		systemctl enable bumblebeed.service
		systemctl start bumblebeed.service
	fi
}

pre_remove()
{
	modprobe -r bbswitch

	if [[ -d /run/openrc ]];then
		rc-update del bumblebee default
		rc-service bumblebee stop
	else
		systemctl disable bumblebeed.service
		systemctl stop bumblebeed.service
	fi
}

post_remove()
{
	if [ -e "${XORGFILE}" ]; then
		rm "${XORGFILE}"
	fi
	if [ -e "${MODULESFILE}" ]; then
		rm "${MODULESFILE}"
	fi
	if [ -e "${MODULESBLACKLIST}" ]; then
		rm "${MODULESBLACKLIST}"
	fi

	mhwd-gpu --check
}

set_bumblebee_driver()
{
	sed -i "/(#)/!s/^[ ]*Driver[ ]*=.*/Driver=$1/g" /etc/bumblebee/bumblebee.conf
}

And change it the way that is needed to make prime work. I have no idea how nvidia prime works and can not test it. Otherwise I would do it :confused:

I’ve a laptop from Station-X, the Lancaster, I’ll enable NV-Prime on. However had no time to do so …

2 Likes

you need something that executes the xrandr commands
(xrandr --setprovideroutputsource …)
maybe could be in xinitrc.d/ (to avoid login manager specific scipt.). Cant test as I dont have any loginmanager

also example for possible switch script see here:

(although need some rework, option for disabling should be added additonal to blacklist, useless stuff removed and maybe also some override of xrandr script to allow xrandr --setprovideroffloadsink for intel and nouveau )

I re-did the process recently:

The most complicated bit is the DM setup; I don’t know how that could be easily automated.

maybe not needed if /etc/X11/xinitrc.d can be used for that.
it seems the link only covers nvidia, not switching between intel and nvidia?

It didn’t work when I tried it. The steps in the thread are the most minimal/efficient that worked for me.

That’s not to say it won’t work though, just that I couldn’t get it to.

1 Like

you could add that script to /etc/profile.d/90-nvidia-prime.sh

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

with something like ´if $XDG_SESSION_TYPE == x11`

Because this script will run on every login and so you can make sure that it will only used on x11 sessions (not on VT or wayland).

For the “options nvidia_drm modeset=1” - is this a stable function now? @philm could you add it to the nvidia driver package as file: /usr/lib/modprobe.d/nvidia-kms.conf if so.

Not according to the 390.25 release notes. :slightly_frowning_face:

this dont work for me,

I created a pkg which should basically work (removed all previous created xrandr and xorg config stuff, also intel and nvidia packages, works without dm), but with login manager (tested with sddm) I cant get it working.
I also tried in an horrible approach to replace (backup) original sddm Xsetup script in pre_install and use own but this don’t work because I cant mess up other package files

I found a possible solution (still nasty but working)

  • split packages in nodm,sddm,lightdm,whateverdm
  • add custom install for dm stuff
  • add hook in case dm is installed or deinstalled and give info that dm has changed and reinstall is needed (or in case of update maybe reapply changes). not a really good solution but

works without dm and with sddm (lightdm no pkg yet). looking for someone who helps testing and can deal with black screen (switching tty works) and is able to restore his previous setting (should be possible via mhwd)

I also tried to create one pkgbuild for multiple dm but didn’t find a way to specify install during prepare(), so decided to spilt per dm

@vetzki it sort of worked for me. As I mentioned here sddm displays on the wrong output. I decided to enable auto-login for now and it works.
I’ve also tried:

Also if you want help in testing let me know I’ve broken it ad-nauseun so I can fix it almost imemdiately

Please don’t cross-post. This thread has an entirely different topic and not appropriate for seeking support on a different issue.

@jonathon okay sorry, the common part I wanted to mention was the problem with the display manager

Is it to do with the above profile script? If not, it’s a different issue (and likely because you haven’t enabled those commands in your DM startup).

I’ve uploaded archives for “nodm”: edit:
see here:

if you’re willing to test, some notes:

  • intel.conf and nvidia.conf in /etc/X11/mhwd.d are included and wont override local files if they already exist. In that case rename/backup (e.g. to intel.conf.bak / nivida.conf.bak) the files

  • also in the past, not sure if its still the case manjaro put keyboard and mouse stuff in intel-mhwd.conf file (or something like that cant remember the name), please split in seperate files (like it should be) in xorg.conf.d
    e.g. 01-keyboard.conf , 02-mouse.conf and put the mouse and keyboard related stuff in the according file

to restore previous state:

  • deinstall package
  • install your current configuration again with mhwd
  • restore intel.conf.bak and nvidia.conf.bak (if you had to backup them like mentioned before)

after installation:
use either
sudo prime-switch -d intel
or
sudo prime-switch -d nvidia
to apply config
(possible to add additional “driver” sections, -d help or -d ? or -d anything_but_correct_keyword shows possible configurations )

  • if you disable display manager, either install nodm pkg or add
    [[ -f /etc/X11/mhwd.d/xrandr_prime.sh ]] && . /etc/X11/mhwd.d/xrandr_prime.sh &
    to e.g. .xinitrc

edit:
some fixes
edit2:
simpler execution of xrandr commands (if nvidia isnt running the xrandr commands dont bother intel or nouveau)
edit3:
pkg for lightdm

I did enable then to be run in sddm. Exactly those xrandr lines.

1 Like

This doesn’t work for me with LightDM; the command has to be set in the lightdm.conf.

1 Like

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

Forum kindly sponsored by