# Video Switching on Lenovo T410s

## burmashave

Hi,

I'm trying to get switchable graphics working on my Lenovo T410s without needing to reboot. The T410s has an Intel on chip GPU (i915) and an nVidia discrete GPU (NVS 3100). So far, I have both working, but in order to switch the GPU, I have to reboot to change the display mode in the BIOS. With the BIOS set to "Integrated" or "Switchable", the Intel GPU works fine; however, the nVidia GPU (using proprietary drivers) works only with the display in the BIOS set to "Discrete". 

To switch the GPU, I have to reboot, set the desired device in the BIOS, switch the xorg.conf file and switch the opengl from nvidia to xorg-x11 or vice versa.

I was unable to get kernel supported GPU Switching (VGA_Switcheroo) working. I get no errors; however, the 'vgaswitcheroo' entry doesn't appear in '/sys/kernel/debug' as it should.

On the other hand, the good folks at the Linux Hybrid Graphics have identified the ACPI procedure call that enables and disables power to the nVidia GPU on the T410s. I have verified that this call powers the nVidia GPU up and down.

The problem seems to be that the nVidia GPU isn't fully recognized with the BIOS set to "Switchable." It shows in lspci and is assigned a driver; however, it does not show an IRQ in /proc/interrupts (although it does show an interrupt in /proc/driver/nvidia/cards/0). Xorg.log.0 only reports that "(EE) Aug 16 21:50:39 NVIDIA(0): Failed to initialize the NVIDIA graphics device PCI:1:0:0. "

I've tried lots of tinkering with configs. There's somewhat of a balance in keeeping everything working as is while tweaking anything. I've combed through lots of posts, here and beyond, and reading requests for information, I have compiled what I hope is a comprehensive and readable set of debug info:

http://burmashave.net/media/files/debug.20100816.txt

The file contains:

[0] uname -a

[1] lspci -vvv (filtered for video devices)

[2] dmesg (filtered for "nvidia")

[3] lsmod

[4] cat /proc/interrupts

[5] cat /proc/driver/nvidia/cards/0 

[6] cat /etc/X11/xorg.conf.nvidia

[7] cat /etc/X11/xorg.conf.intel

[8] cat /usr/src/linux/.config

[9] dmesg (full)

[10] emerge --info

[11] /var/log/Xorg.0.log (nVidia)

[12] /var/log/Xorg.0.log (nVidia)

[13] cat /boot/grub/grub.conf

I wanna get this going and post procedures for others. By the way, for any other T410s owners, the attached configs have everything working except the camera.

----------

## chithanh

I am not fully sure, but I think the proprietary driver does not support switchable graphics at this time. Maybe try if nouveau works.

----------

## burmashave

Thanks, I'll give it a go. I had a brief attempt at the Nouveau drivers, but I'll give it another go, and do what research I can about the proprietary driver. I appreciate any new directions to try at this point.

----------

## drizzt

Well I can't exactly speak for Intel/Nvidia but I have ATI (5450) / Intel running with switching on my Acer 3820. I use the kernel vga_switcheroo mechanism, but this one works only with both drivers using KMS afaik.

I therefor have intel and ati running on free drivers. This requires the live ebuild to be used for ATI since the in tree version does not support the 5450( at least it didn't work on my laptop).

But the use is very limited at the moment since the ATI is only supported in basic (unaccelerated) 2D mode. Because of that I always enable Intel at the moment and disable ATI.

Drizzt

P.S. I disable the ATI *after* I started X(for powersave reasons), otherwise X takes veeeery long to start. Seems like ATI driver tries to access ATI card on X startup even if not used.

----------

## burmashave

I haven't had much time to work on this lately, but I wanted to give an update.

I took another look at the Nouveau drivers, but the prob., as I understand it, is that the Nouveau drivers don't support 3D acceleration. I chose the T410s because I wanted a Thinkpad with a good GPU, so living without 3D acceleration doesn't really work for me. When the Nouveau drivers get there, I'll take another look at them.

I'm still looking at the proprietary drivers. They may not support switching; however, I'm assuming I'd have to restart X to get any kind of switching working anyway. It seems that there should be a way to stop X, unload the Intel drivers and then start X with the nVidia proprietary driver. At the moment, the prob seems to be that the nVidia GPU isn't recognized, even though it is powered up. I know that folks with desktops have reported that nVidia GPU's don't play well if they are not the first recognized. This is the path I'm working down at the moment.

On the other hand, I can power the nVidia GPU up and down using ACPI calls when the BIOS is set to switchable. The overall how-to is here:

http://linux-hybrid-graphics.blogspot.com/2010/07/using-acpicall-module-to-switch-onoff.html

It essentially involves building the kernel module from these sources: 

http://github.com/mkottman/acpi_call

Once the acpi_call.ko module is built, it can be inserted, and then the nVidia GPU can be switched on and off:

```
echo "\_SB.PCI0.PEG.VID._ON" > /proc/acpi/call
```

```
echo "\_SB.PCI0.PEG.VID._OFF" > /proc/acpi/call
```

The power usage can be confirmed (assuming the AC is disconnected and an aux. battery is not being used):

```
cat /proc/acpi/battery/BAT0/state
```

Anyhoo, I use a script to do the switching and another to monitor power usage:

burmashave.net/media/files/acpi_scripts.tgz

Note that I use a template that includes error handling for all my scripts, so you'll find the meat of the script at the bottom. As for the toggle_pwr.sh script, you'll need to specify the location for the acpi_call.ko module (see User Configuration near top of script). The rate.sh script takes an argument of seconds between output. This defaults to 3. You can use watch instead of my simple script as in:

```
watch cat /proc/acpi/battery/BAT0/state
```

But watch doesn't show the power use trend.

Bottom line: At the moment, I'd like to figure out how to force the nVidia GPU to be recognized before the onboard Intel GPU.

----------

