# NVidia Optimus on FreeBSD



## phpwolf (Mar 8, 2012)

Hello guys,

I have an Asus laptop who has a video card with NVidia Optimus Technology. I found some recent posts regarding GEM/KMS support on FreeBSD9 & X updates to v7.5.2. 

I made some research and I found very important stuff about this update here:

http://blogs.freebsdish.org/

Unfortunately, I found many errors when I tried to apply the drm patches to the kernel.

I'm not an experienced FreeBSD user but I really want to run BSD on my laptop. I'm a game developer and I want to make games for FreeBSD, that's why I need acceleration on my video card.

Can you help me, please?

Also, I opened a similar thread on PC-BSD forum:

http://forums.pcbsd.org/showthread.php?t=14782


Thanks in advance,
phpwolf


----------



## xibo (Mar 8, 2012)

If you need graphics just use the geforce card of that laptop, which should work with the x11/nvidia-driver and don't bother with the igp 

The KMS effort is primarily for those who don't have a dedicated nvidia chip. X11 doesnot support nVidia optimus because it's bound the the adapter it was started with. You can of cause start X11 on both adapters and switch the active contexts, but I doubt that serves power saving which is what optimus is there for.


----------



## Beastie (Mar 8, 2012)

NVidia said they won't provide support for the Optimus technology on Linux and since Xorg is mostly developed by Linux people and only then ported to other systems...

Actually I believe it's barely supported on Windows XP and only has full support on Windows 7.

From what I've read on the subject, some machines let you disable Optimus in the BIOS, others have a hardware switch (e.g. some Lenovo IdeaPads?), and some provide no option and will just blackout if you try to disable the IGP.


----------



## phpwolf (Mar 9, 2012)

xibo said:
			
		

> If you need graphics just use the geforce card of that laptop, which should work with the x11/nvidia-driver and don't bother with the igp
> 
> The KMS effort is primarily for those who don't have a dedicated nvidia chip. X11 doesnot support nVidia optimus because it's bound the the adapter it was started with. You can of cause start X11 on both adapters and switch the active contexts, but I doubt that serves power saving which is what optimus is there for.



Thank you for your suggestions. Unfortunately, the NVidia driver doesn't work, the VESA driver doesn't work ether. My laptop is an ASUS X53-S with NVidia GT520M + an Intel video card (maybe i950, but I'm not very sure). From what I understand, it seems my only option on FreeBSD is to use the Intel driver instead of NVida's one (the Torvalds OS use also the Intel video card via Bumblebee project). Is quite funny, even the win7 native driver use the Intel chipset by default for d3d rendering, and this is happen because the NVidia driver crashes random (there is nothing wrong with my laptop, the culprit is the NVidia native driver, many guys has the same problem as me).

One more note: my laptop hasn't the BIOS swith from Intel to Nvidia. I know, this is happen when you try to buy cheap stuff and/or you don't have a choice to buy good one 

Because I'm a new FreeBSD user, I was blocked when I tried to apply the drm patch to the FreeBSD kernel. Yesterday I search on all threads from this forum and I found some precious informations - I hope I'll spend my weekend trying to solve this annoying problem.

If everything goes well, my plan is to start a personal project - making casual games for FreeBSD. I love the BSD license and I think is a very good opportunity for me to make games for this platform.

Thanks a lot for your answers, any suggestion is welcome. I'll continue to post my progress here, but please, don't forget I'm new to BSD and maybe I'll made some basic mistakes, so please, be gentle with me If I ask you stupid things.


----------



## xibo (Mar 9, 2012)

Have you tried using the VESA driver for both the geforce and the intel ipg? If not, try to use VESA on Intel Card.
Maybe something useful can be found in /var/log/xorg.log and/or by running dmesg.


----------



## dennylin93 (Mar 10, 2012)

@phpwolf: I also have an Asus laptop (A53SV). Specs are very similar to yours.

GNOME is running fine for me, so I think the patches should work on your laptop, too.

Steps:

Grab 10-CURRENT using csup or SVN
Apply the latest all.X.Y.patch in http://people.freebsd.org/~kib/drm/
Rebuild world and kernel
Fetch Ports using csup or portsnap
Fetch the development repo for X11: http://wiki.freebsd.org/Xorg
 Add 
	
	



```
WITH_NEW_XORG=YES
WITH_KMS=YES
```
 to /etc/make.conf
Install the required ports (X.Org, GNOME/KDE/XFCE, etc.)

I've tried installing x11/nvidia-driver, but it causes my computer to reboot when X.Org starts. Anyway, it will work fine without the GPU.

There's also a backport of all.X.Y.patch for 9-STABLE (it isn't maintained by kib@), so you don't have to run 10-CURRENT. There's a link to it in a post on this forum.


----------



## phpwolf (Mar 17, 2012)

dennylin93 said:
			
		

> @phpwolf: I also have an Asus laptop (A53SV). Specs are very similar to yours.
> 
> GNOME is running fine for me, so I think the patches should work on your laptop, too.
> 
> ...



Thanks. I just compiled all the stuff using the Toto's instructions (see this post: 	
http://forums.freebsd.org/showthread.php?t=21852&page=5), everything was compiled without errors.

The X initialization with Intel driver seems to work, but now I have two BIG problems:

1. the display has a lot of artifacts at the top of the screen (random pixels).
2. the mouse buttons don't work (the mouse cursor moves as it should but the buttons don't trigger anything).

I tried this with XFce4, fvwm2, fluxbox and twm. Another strange behavior: if I press some keys (for example alt+f2 in XFce4 to open the run dialog window) nothing happens and the random pixels (screen artifacts) seem to multiply - I'm a happy guy with so many random pixels )))

Any idea how can I fix this?


----------



## nemysis (May 13, 2013)

I have asked on the PC-BSD forum about new port of x11/bumblebee. Please test it because I don't have a laptop with Nvidia Optimus technology.


----------



## TommyC7 (May 19, 2013)

Hi phpwolf,

I too have a laptop with Nvidia Optimus technology (except it's HP instead of ASUS). What I did was similar to what you have done. However, I opted to use just the Intel GPU instead of both (and my BIOS, even after being flashed in Windows 7 doesn't come with an option to disable one or the other either).

FreeBSD 9.0 did not have enough support for the Intel GPU in an Nvidia Optimus setup, but 9.1 did so with my 9.0 installation (with X11 installed) I just simply upgraded to 9.1 as per the FreeBSD documentation.

(This is the first difference since I'm assuming you followed dennylin93's advice and upgraded to 10-CURRENT).

Then I added

```
WITH_NEW_XORG=YES
WITH_KMS=YES
```

to my /etc/make.conf and then I just rebuilt X11 (as per the FreeBSD documentation) and installed x11-drivers/xf86-video-intel.

Then I just ran (as root) `Xorg -configure`, put the configuration file in the proper location (of which I have heard can be either /usr/local/etc/X11 or /etc/X11 and then `startx` worked like a charm.

One DE I would not recommend you use an Intel GPU with is KDE4 (not sure about KDE3). A few problems I ran into were that sometimes when KDE's screensaver daemon was running and I was trying to log back in, instead of showing me a login prompt it would just freeze the screen (and the animated screensaver) and render the system unusable. Shutting down via KDE would sometimes hang and just never shutdown. I want to clarify that the screensaver and shutting down did still work on some occasions but it was about a 50% chance of working properly.

One thing about the Intel GPU (at least in 9.1 anyways, not sure about 10-CURRENT) is that you definitely shouldn't try to switch tty's (no matter the DE or WM) because this too will render the system unusable (this has already been reported in the past, so perhaps there is a fix for it in 10-CURRENT but as previously stated I do not follow 10-CURRENT).


----------



## kerlin (Jan 17, 2015)

Some up to date info related to support nVidia Optimus on FreeBSD:
https://wiki.freebsd.org/OptimusVideoSupport

So all who need it, you are welcome to test and reports your success or unsuccess story.


----------



## rami_bachar (Feb 8, 2015)

kerlin said:


> Some up to date info related to support nVidia Optimus on FreeBSD:
> https://wiki.freebsd.org/OptimusVideoSupport
> 
> So all who need it, you are welcome to test and reports your success or unsuccess story.


I have the same problem

iI have HD4600 + NVIDIA (Lenovo G710)
Intel driver doesn't work for me with any version of FreeBSD (the best iI get is black screen).
As iI understand the options

```
WITH_NEW_XORG=YES
WITH_KMS=YES
```
are no longer needed (they are ignored when you get the current SVN source). I would use the NVIDIA as normal card if i could (dont care about battery life at the moment). It is not really documented and it looks  that the make.conf options are no longer valid because as it written the Linux driver is already there:
https://wiki.freebsd.org/Graphics/Update i915 GPU driver to Linux 3.8
If someone could help with explaining how to make it work that would be very helpful
using a VESA driver and mark it solved is not really a nice solution.

Thanks


----------



## wblock@ (Feb 8, 2015)

FreeBSD does not yet support the Haswell video, the only option available at the moment is the vesa driver.  Optimus means there is an additional Nvidia GPU only, it does not have separate video memory.  This is not supported on FreeBSD by Nvidia.  There are third-party attempts (see link to the wiki above), but for that to work will probably require the Haswell support.


----------



## rami_bachar (Feb 8, 2015)

Can you explain what this link says?
https://wiki.freebsd.org/Graphics/Update i915 GPU driver to Linux 3.8
This comes from this page:
https://wiki.freebsd.org/Graphics
And on the Haswell section it links to *Project finished*.
I'm really confused from all this and after many times of trying I give up.  I guess i just don't understand at the end if its supported or not.


----------



## wblock@ (Feb 8, 2015)

It says the i915 driver was updated, but to the Linux 3.5 version.


----------



## rami_bachar (Feb 8, 2015)

wblock@ said:


> It says the i915 driver was updated, but to the Linux 3.5 version.


Well I guess I have problems with understanding, for me it's confusing, when under Haswell notes i915 it says project finished? It means Linux 3.5 version project finished? If so what is the right Linux project that the i915 should work with HD4600?
Thanks.


----------



## wblock@ (Feb 8, 2015)

I don't have any more information than it says there.  You could try a snapshot of FreeBSD 11-CURRENT, where that was committed, to see if it supports Haswell now.


----------



## rami_bachar (Feb 8, 2015)

It's not working, both on 10.1 stable from 2/2 and 11 current from 2/2 (r278031) - black screen both, although in my understanding it should work, maybe I just don't know how to make it work.


----------



## ondra_knezour (Feb 8, 2015)

There is a special to do entry on the graphics wiki page for adding Haswell support. Also their blog clearly states that there is support for chips up to Ivy Bridge in this commit, Haswell will come later, see http://blogs.freebsdish.org/graphics/2015/02/07/update-to-the-i915-kernel-driver/


----------



## rami_bachar (Feb 8, 2015)

Thanks.  The next try I will do when this page https://wiki.freebsd.org/Graphics will say Haswell Works.


----------

