Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Switchable Graphics on Asus UL30vt (asus-vga-switcheroo)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Sat Oct 02, 2010 4:36 pm    Post subject: Switchable Graphics on Asus UL30vt (asus-vga-switcheroo) Reply with quote

See later post for new method

Ebuild now in sunrise

My asus UL30vt has both an nvidia card and a lower-powered (in both senses) intel card. I recently got switching between the two down, thanks in large part to the people in the ubuntu forums In my current situation.

  • I can chose which card to use at boot time in the bios.
  • I don't have to do anything with config files
  • The other card is powered down
  • the brightness keys work for both cards (also I have an init.d service that manages brightness)


The forum posts outline how to semi-permanently pick one card via a bios setting (SATA->compatible turns off the intel card for no clear reason.) or a module (the asus_nvidia module in the first post, not one of the later ones) deactivates the nvidia card. This works fine, if you don't actually want to switch. The problems with this plan are:

  • It requires editing xorg.conf
  • Loading the asus_nvidia module when you are using the nvidia card, naturally causes a black screen.
  • the brightness control system is different with the two cards.


The first problem was solved for me by the xorg people. Gentoo seems to be superior to ubuntu in this respect. My xorg runs fine in both configurations with no xorg.conf so no problems there. I stumbled on a solution to the other problems while taking the advice of powertop. Powertop suggested I lower the power going to my sata chipset or something. The command it suggested was:
Code:
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
I put this in /etc/conf.d/local.start, and then while messing around, I noticed that it wasn't working when I was using my nvidia card. The random sata setting that turns off the nvidia card in the bios also caused this /sys/ file to not be created. So I could use its existence as a test for the bios setting.

Thus I put the module load line in local.start, so I could test for this, and not in modules.autoload.d. The same test allowed me to control the backlight in either case.

The only final problem was the module needs to be reloaded every time you hibernate. I was tempted to put it in my /etc/hibernate/common.conf as ReloadModules or somesuch, but that would cause it to be reloaded no matter which card I was using. Thus I put it under UnloadModules, and put local under ServicesRestart. Without further ado here are the relevant files:

/etc/conf.d/local.start
Code:

# /etc/conf.d/local.start

# This is a good place to load any misc programs
# on startup (use &>/dev/null to hide output)

echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
if [ -f "/sys/class/scsi_host/host0/link_power_management_policy" ] ; then
   echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
   modprobe asus_nvidia
fi


/etc/conf.d/lcd-dim
Code:

# brightness level in ac mode. (intel is in hex)
NVIDIA_NORMAL=100
INTEL_NORMAL=ff

# brightness level in battery mode. (intel is in hex.)
NVIDIA_DIM=11
INTEL_DIM=10


/etc/init.d/lcd-dim
Code:
#!/sbin/runscript

start() {
        ebegin "Setting LCD brightness low"
        if [ -e /sys/class/scsi_host/host0/link_power_management_policy ]
        then
                setpci -s 00:02.0 F4.B=${INTEL_DIM}
        else      
                echo "${NVIDIA_DIM}" > /proc/acpi/video/VGA1/LCDD/brightness
        fi
        eend $?
}

stop () {
        ebegin "Setting LCD brightness high"
        if [ -e /sys/class/scsi_host/host0/link_power_management_policy ]
        then
                setpci -s 00:02.0 F4.B=${INTEL_NORMAL}
        else
                echo "${NVIDIA_NORMAL}" > /proc/acpi/video/VGA1/LCDD/brightness
        fi
        eend $?
}


That is the basic part, now for the hotkey acpi event files:

/etc/acpi/events/bl-key-up
Code:
event=hotkey ATKD 0000001
action=/etc/acpi/actions/bl_key_up.sh


/etc/acpi/events/bl-key-down
Code:
event=hotkey ATKD 0000002
action=/etc/acpi/actions/bl_key_down.sh


and the corresponding actions:

/etc/acpi/actions/bl_key_up.sh:
Code:

#!/bin/bash

if [ -e /sys/class/scsi_host/host0/link_power_management_policy ]
then
   brightness=$((0x`setpci -s 00:02.0 F4.B`+16));
   if [ $brightness -gt $((0xff)) ] ; then
      brightness=$((0xff));
   fi
   setpci -s 00:02.0 F4.B=`printf '%x' $brightness`;
else
   brightness=$((`tail -1 /proc/acpi/video/VGA1/LCDD/brightness | cut -f2 -d" "`+6))
   if [ $brightness -gt 60 ]
   then
      brightness=$((brightness+1))
   fi
   if [ $brightness -gt 100 ]
   then
      brightness=100
   fi
   echo ${brightness}
        echo ${brightness} > /proc/acpi/video/VGA1/LCDD/brightness
fi


/etc/acpi/actions/bl_key_down.sh:
Code:
#!/bin/bash

if [ -e /sys/class/scsi_host/host0/link_power_management_policy ]
then
   brightness=$((0x`setpci -s 00:02.0 F4.B`-4));
   if [ $brightness -lt 0 ] ; then
      brightness=1;
   fi
   setpci -s 00:02.0 F4.B=`printf '%x' $brightness`;
else
   brightness=$((`tail -1 /proc/acpi/video/VGA1/LCDD/brightness | cut -f2 -d" "`-7))
   if [ $brightness -lt 60 ]
   then
      brightness=$((brightness+1))
   fi
   if [ $brightness -lt 5 ]
   then
      brightness=5
   fi
   echo ${brightness}
        echo ${brightness} > /proc/acpi/video/VGA1/LCDD/brightness
fi


Well, I hope that helps anyone else with the same or a similar laptop. If you came here from the ubuntu forums, sorry this post is rather technical and gentoo-specific. I hope you can adjust it for ubuntu.


Last edited by Nicias on Sun May 29, 2011 8:45 pm; edited 4 times in total
Back to top
View user's profile Send private message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Sat Oct 02, 2010 5:55 pm    Post subject: Reply with quote

I also have an ebuild for the module, if someone wants it.
Back to top
View user's profile Send private message
josedb
Apprentice
Apprentice


Joined: 03 Nov 2006
Posts: 167

PostPosted: Thu Dec 23, 2010 7:58 am    Post subject: Reply with quote

will be apreciated. Hope this works on ul80 series, seems to be no problem.
Back to top
View user's profile Send private message
josedb
Apprentice
Apprentice


Joined: 03 Nov 2006
Posts: 167

PostPosted: Mon Dec 27, 2010 4:31 pm    Post subject: Reply with quote

Asus UL80vt here
Geforce m210
Intel 4500


Code:
jose-mov ~ # /etc/init.d/lcd-dim start
/etc/init.d/lcd-dim: línea 4:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 5:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 6:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 7:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 8:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 9:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 10:  : no se encontró la orden
/etc/init.d/lcd-dim: línea 11:  : no se encontró la orden
 * ERROR: lcd-dim failed to start


Code:
jose-mov ~ # sh /etc/acpi/actions/bl_key_down.sh
/etc/acpi/actions/bl_key_down.sh: línea 6: error sintáctico cerca del elemento inesperado `then'
/etc/acpi/actions/bl_key_down.sh: línea 6: `   if [ $brightness -lt 0 ] ; then '



Code:
jose-mov ~ # dmesg |grep asus
[    3.313799] asus_laptop: Asus Laptop Support version 0.42
[    3.385137] asus_laptop:   UL80VT model detected
[    3.385594] asus_laptop: Backlight controlled by ACPI video driver
[    3.385652] input: Asus Laptop extra buttons as /devices/platform/asus_laptop/input/input7



setpci -s 00:02.0 F4.B=`printf '%x' $brightness`; works for hexadecimal values
Back to top
View user's profile Send private message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Tue Jan 25, 2011 11:23 pm    Post subject: Reply with quote

Sorry for the delay, life here has been somewhat hectic. Here is my ebuild:

Code:
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

inherit linux-mod eutils

DESCRIPTION="modules to turn of nvidia card for asus laptops"
HOMEPAGE="http://usbirboy.sourceforge.net/"
SRC_URI="${PN}.tgz"

SLOT="0"
KEYWORDS="alpha amd64 ia64 ppc ppc64 x86"
LICENSE="GPL-2"
IUSE=""

S=${WORKDIR}/${PN}

DEPEND=""
RDEPEND=""

MODULE_NAMES="asus_nvidia(acpi:${S})"
BUILD_TARGEST="default"

pkg_setup() {
        linux-mod_pkg_setup || die
}


src_compile(){
        linux-mod_src_compile || die
}

src_install(){
        linux-mod_src_install || die
}
Two things.

  • I have no idea where I got the tarball from. I'd put it up if I knew someplace to dump it (like pastebin for files.) its less than 4k
  • The ebuild only works about half the time. Go figure.


On to your specific question. It looks like the files got corrupted somewhere along the way. I don't see why the init script should be giving what I guess is "command not found" every line.
Back to top
View user's profile Send private message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Sun May 08, 2011 8:44 pm    Post subject: Reply with quote

Ok, someone has worked out how to use the switcheroo code in the kernel for this laptop. Their git repo is at:

https://github.com/awilliam/asus-switcheroo

I packaged that and put in a bug for a new ebuild

It works for me with the closed-source nvidia driver. When I start up, the nvidia card is powered off, and use the intel card. If I want to, I can run a command and switch to the nvidia card, at the cost of losing my VT's. To switch back I have to restart, but no mucking around in the BIOS.

I also have modified my LCD dimming scripts, and I can put them up if there is interest.
Back to top
View user's profile Send private message
anarchist
Apprentice
Apprentice


Joined: 12 Jul 2002
Posts: 264

PostPosted: Sun May 15, 2011 7:46 pm    Post subject: Reply with quote

I would be very interested in getting the brightness scripts.

The switcheroo itself works great for me. Thanks for that :)
Back to top
View user's profile Send private message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 390

PostPosted: Sun May 15, 2011 10:48 pm    Post subject: Reply with quote

No problem. Here are my scripts, as written they depend on using the closed source nvidia drivers:

/etc/init.d/lcd-dim
Code:
#!/sbin/runscript

start() {
    if [ -f /proc/acpi/video/VGA1/LCDD/brightness ]
    then
        ebegin "Setting LCD brightness"
        if ( lsmod | grep nvidia )
        then
                echo "${NVIDIA_DIM}" > /proc/acpi/video/VGA1/LCDD/brightness
        else           
                setpci -s 00:02.0 F4.B=${INTEL_DIM}
        fi
        eend $?
    else
        ewarn "Setting LCD brightness is not supported."
    fi


}

stop () {
    if [ -f /proc/acpi/video/VGA1/LCDD/brightness ]
    then
        ebegin "Setting LCD brightness"
        if [ -e /sys/class/scsi_host/host0/link_power_management_policy ]
        then
                setpci -s 00:02.0 F4.B=${INTEL_NORMAL}
        else
                echo "${NVIDIA_NORMAL}" > /proc/acpi/video/VGA1/LCDD/brightness
        fi
        eend $?
    else
        ewarn "Setting LCD brightness is not supported."
    fi
}


/etc/conf.d/lcd-dim
Code:
# See /proc/acpi/video/VGA1/LCDD/brightness for available values
# Please read /usr/src/linux/Documentation/thinkpad-acpi.txt

# brightness level in ac mode. Default is 7. (intel is in hex)
NVIDIA_NORMAL=100
INTEL_NORMAL=ff

# brightness level in battery mode. Default is 4. (intel is in hex.)
NVIDIA_DIM=11
INTEL_DIM=10


/etc/acpi/events/bl-key-down
Code:
# replace "ac_adapter" below with the event generated on your laptop
# For example, ac_adapter.* will match ac_adapter AC 00000080 00000000
event=hotkey ATKD 0000002
action=/etc/acpi/actions/bl_key_down.sh


/etc/acpi/events/bl-key-up
Code:
# replace "ac_adapter" below with the event generated on your laptop
# For example, ac_adapter.* will match ac_adapter AC 00000080 00000000
event=hotkey ATKD 0000001
action=/etc/acpi/actions/bl_key_up.sh


/etc/acpi/actions/bl_key_down.sh
Code:
#!/bin/bash

if ( lsmod | grep nvidia )
then
   brightness=$((`tail -1 /proc/acpi/video/VGA1/LCDD/brightness | cut -f2 -d" "`-7))
   if [ $brightness -lt 60 ]
   then
      brightness=$((brightness+1))
   fi
   if [ $brightness -lt 5 ]
   then
      brightness=5
   fi
   echo ${brightness}
        echo ${brightness} > /proc/acpi/video/VGA1/LCDD/brightness
else
   brightness=$((0x`setpci -s 00:02.0 F4.B`-16));
   if [ $brightness -lt 1 ] ; then
      brightness=1;
   fi
   setpci -s 00:02.0 F4.B=`printf '%x' $brightness`;
fi


/etc/acpi/actions/bl_key_up.sh
Code:
#!/bin/bash

if ( lsmod | grep nvidia )
then
   brightness=$((`tail -1 /proc/acpi/video/VGA1/LCDD/brightness | cut -f2 -d" "`+6))
   if [ $brightness -gt 60 ]
   then
      brightness=$((brightness+1))
   fi
   if [ $brightness -gt 100 ]
   then
      brightness=100
   fi
   echo ${brightness}
        echo ${brightness} > /proc/acpi/video/VGA1/LCDD/brightness
else
   brightness=$((0x`setpci -s 00:02.0 F4.B`+16));
   if [ $brightness -gt $((0xff)) ] ; then
      brightness=$((0xff));
   fi
   setpci -s 00:02.0 F4.B=`printf '%x' $brightness`;
fi


I hope that helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum