commit f5ccd68db6ab76fa6fe7b931a89396ae75e15b33 Author: Kolan Sh Date: Fri Dec 23 23:15:11 2011 +0300 Gentoo initial tree diff --git a/etc/X11/xorg.conf.intel.snail b/etc/X11/xorg.conf.intel.snail new file mode 100644 index 0000000..5df86c0 --- /dev/null +++ b/etc/X11/xorg.conf.intel.snail @@ -0,0 +1,44 @@ +Section "Module" + Load "GLcore" + Load "dbe" + Load "dri" + Load "dri2" + Load "freetype" + Load "ddc" + Load "extmod" + Load "int10" + Load "vbe" + Load "dbe" + Load "glx" +EndSection + +Section "Files" + FontPath "/usr/share/fonts/misc:unscaled" + FontPath "/usr/share/fonts/75dpi:unscaled" + FontPath "/usr/share/fonts/100dpi:unscaled" + FontPath "/usr/share/fonts/corefonts" + FontPath "/usr/share/fonts/freefonts" + FontPath "/usr/share/fonts/terminus" + FontPath "/usr/share/fonts/ttf-bitstream-vera" + FontPath "/usr/share/fonts/unifont" + FontPath "/usr/share/fonts/artwiz-latin1" + FontPath "/usr/share/fonts/cronyx" + FontPath "/usr/share/fonts/cyrillic" + FontPath "/usr/share/fonts/dejavu" + FontPath "/usr/share/fonts/droid" + FontPath "/usr/share/fonts/intlfonts" + FontPath "/usr/share/fonts/liberation-fonts" + FontPath "/usr/share/fonts/urw-fonts" +EndSection + +Section "Device" + Identifier "Device0" + Driver "intel" + VendorName "onboard" + BusID "BusIDIntel" +EndSection + +Section "Extensions" + Option "Composite" "Disable" + Option "RENDER" "Enable" +EndSection diff --git a/etc/X11/xorg.conf.nvidia.snail b/etc/X11/xorg.conf.nvidia.snail new file mode 100644 index 0000000..1c0a800 --- /dev/null +++ b/etc/X11/xorg.conf.nvidia.snail @@ -0,0 +1,63 @@ +Section "ServerLayout" + Identifier "Layout0" +EndSection + +Section "Module" + Disable "dri" + Disable "dri2" + Load "dbe" + Load "extmod" + Load "glx" + Load "record" + Load "freetype" + Load "type1" +EndSection + +Section "Device" + Identifier "Device1" + Driver "nvidia" + VendorName "NVIDIA Corporation" + BusID "BusIDNvidia" + Option "IgnoreEDID" "False" + Option "UseEDID" "FALSE" + Option "NoDDC" "True" + Option "ConnectedMonitor" "CRT-0" + + Option "AllowDDCCI" "True" + Option "AllowDFPStereo" "True" + Option "AllowGLXWithComposite" "False" + Option "NoBandWidthTest" "False" + Option "ConnectToAcpid" "True" + Option "ConstantDPI" "True" + # Option "Dac8Bit" "True" + Option "DisableGLXRootClipping" "True" + Option "DamageEvents" "True" + Option "ExactModeTimingsDVI" "True" + Option "NoFlip" "False" + Option "ForceStereoFlipping" "True" + Option "IncludeImplicitMetaModes" "True" + Option "NoLogo" "True" + Option "MultisampleCompatibility" "True" + Option "Overlay" "True" + Option "CIOverlay" "True" + Option "OverlayDefaultVisual" "True" + Option "RandRRotation" "True" + Option "NoRenderExtension" "False" + Option "RenderAccel" "True" + Option "AddARGBGLXVisuals" "True" + Option "CoolBits" "1" + # Battery settings: + Option "RegistryDwords" "PowerMizerLevel=0x3" + # auto perf depend on temp + Option "RegistryDwords" "PerfLevelSrc=0x3333" +EndSection + +Section "Extensions" + Option "Composite" "Disable" + Option "RENDER" "Enable" +EndSection + +Section "ServerFlags" + Option "AllowEmptyInput" "yes" +EndSection + diff --git a/etc/init.d/snail b/etc/init.d/snail new file mode 100755 index 0000000..3cf6c1b --- /dev/null +++ b/etc/init.d/snail @@ -0,0 +1,26 @@ +#!/sbin/runscript + +DAEMON=/usr/bin/X +DAEMON_ARGS="-ac -config /etc/X11/xorg.conf.nvidia -sharevts -modulepath /usr/local/lib/snail -nolisten tcp -noreset :1 vt9" +PIDFILE=/tmp/.X1-lock + +depend() { + need xdm +} + +start() { + ebegin "Starting bumblebee nVidia Optimus" + snail.nv_pwr_on || eend -1 + ! ps -p `cat $PIDFILE 2>&1` > /dev/null 2>&1 || eend -1 + export LD_LIBRARY_PATH=/usr/lib/opengl/nvidia/lib:/usr/lib/opengl/nvidia/lib + start-stop-daemon --start --quiet --background --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS + eend $? +} + +stop() { + ebegin "Stopping bumblebee nVidia Optimus" + kill `cat $PIDFILE 2>&1` > /dev/null 2>&1 ; sleep 1 ; kill -9 `cat $PIDFILE 2>&1` > /dev/null 2>&1 + snail.nv_pwr_off || eend -1 + eend $result +} + diff --git a/etc/local.d/snail.start b/etc/local.d/snail.start new file mode 100644 index 0000000..99c819c --- /dev/null +++ b/etc/local.d/snail.start @@ -0,0 +1,3 @@ +# /etc/conf.d/local.start + +snail.nv_pwr_off diff --git a/snail-0.0.1.ebuild b/snail-0.0.1.ebuild new file mode 100644 index 0000000..429051f --- /dev/null +++ b/snail-0.0.1.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=4 +inherit eutils + +DESCRIPTION="Snail - nVidia Optimus support in a simple way" + +SRC_URI="ftp://backbone.myftp.org/projects/snail/snail-0.0.1.tar.gz" + +HOMEPAGE="http://backbone.myftp.org/projects/snail" + +KEYWORDS="-* ~x86 ~amd64" + +SLOT="0" + +LICENSE="GPL-3" + +IUSE="" + +DEPEND="x11-drivers/nvidia-drivers" + +RDEPEND="${DEPEND}" + +src_prepare() { + echo "src_prepare=`pwd`" >>/tmp/snail.log +} + +src_configure() { + echo "src_configure=`pwd`" >>/tmp/snail.log +} + +src_compile() { + echo "src_compile=`pwd`" >>/tmp/snail.log +} + +src_install() { + echo "src_install=`pwd`" >>/tmp/snail.log +} + +pkg_postinst() { + echo "src_postinst=`pwd`" >>/tmp/snail.log +} + diff --git a/usr/local/bin/nvrun b/usr/local/bin/nvrun new file mode 100755 index 0000000..2b476dd --- /dev/null +++ b/usr/local/bin/nvrun @@ -0,0 +1,47 @@ +#!/bin/sh + +LOCK_FILE=/tmp/.snail.nvrun.lock + +( + flock -n 9 + + if [ 0 -ne $? ]; then + echo "Cann't lock $COUNT_FILE. Exiting..." + exit -1 + fi + + snail.nvstat || snail.nvon + + if [ 0 -ne $? ]; then + echo "Cann't switch on nVidia graphics. Exiting..." + exit -1 + fi + +) 9>$LOCK_FILE || exit $? + +snail.nvrun "$@" + +( + flock -n 9 + + if [ 0 -ne $? ]; then + echo "Cann't lock $COUNT_FILE. Exiting..." + exit -1 + fi + + pgrep snail.nvrun &>/dev/null + + if [ 0 -eq $? ]; then + echo "Other applications still use nVidia chip. So we aren't switching off it, just exiting..." + exit 0 + else + snail.nvoff + [ 0 -ne $? ] && echo "Error: Cann't switch off nVidia graphics. Exiting..." && exit -1 + echo "nVidia chip powered off." + exit 0 + fi + +) 9>$LOCK_FILE + +exit $? + diff --git a/usr/local/bin/snail.nv_pwr_off b/usr/local/bin/snail.nv_pwr_off new file mode 100755 index 0000000..06c30ba --- /dev/null +++ b/usr/local/bin/snail.nv_pwr_off @@ -0,0 +1,95 @@ +#!/bin/sh + +model=`sudo snail.dmidecode` + +let retry=5 +while [ $retry -ne 0 ]; do + + case "$model" in + M11XR2) + modprobe -r nvidia \ + && echo '\_SB.PCI0.P0P2.PEGP.NVOP 0 0x100 0x1A {255,255,255,255}' > /proc/acpi/call \ + && echo '\_SB.PCI0.P0P2.PEGP._PS3' > /proc/acpi/call \ + && exit 0 + ;; + 1015PN) + modprobe -r nvidia \ + && echo '\OSGS 0x03' > /proc/acpi/call \ + && exit 0 + ;; + 1215N) + modprobe -r nvidia \ + && echo '\_SB.PCI0.P0P4.GFX0._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \ + && echo '\_SB.PCI0.P0P4.GFX0._PS3' > /proc/acpi/call \ + && exit 0 + ;; + K42Jc|K52Jc|N53Jf|N53Jg|N71Jv|N73Jf|P52Jc|PL80Jt|U30Jc|U33Jc|U35Jc|U36Jc|UL80Jt) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call \ + && exit 0 + ;; + N61Jv|N73Sv) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEGR.GFX0.DOFF' > /proc/acpi/call \ + && exit 0 + ;; + P31Jg) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG1.GFX0._PS3' > /proc/acpi/call \ + && exit 0 + ;; + U43Jc) + modprobe -r nvidia \ + && echo '\_SB.PCI0.RP00.VGA._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \ + && echo '\_SB.PCI0.RP00.VGA._PS3' > /proc/acpi/call \ + && exit 0 + ;; + UL30Vt) + modprobe -r nvidia \ + && echo '\_SB.PCI0.P0P1.VGA._OFF' > /proc/acpi/call \ + && exit 0 + ;; + E6420) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG0.VID._OFF' > /proc/acpi/call \ + && exit 0 + ;; + InspironN5110|XPSL702X) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG0.PEGP._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \ + && echo '\_SB.PCI0.PEG0.PEGP._PS3' > /proc/acpi/call \ + && exit 0 + ;; + Vostro3300|Vostro3500) + modprobe -r nvidia \ + && echo '\_SB.PCI0.P0P1.PEGP._OFF' > /proc/acpi/call \ + && exit 0 + ;; + XPS15) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call \ + && exit 0 + ;; + ThinkPadT410) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG.VID._PS3' > /proc/acpi/call \ + && echo '\_SB.PCI0.PEG.VID._OFF' > /proc/acpi/call \ + && exit 0 + ;; + ThinkPadT420) + modprobe -r nvidia \ + && echo '\_SB.PCI0.PEG.VID._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \ + && echo '\_SB.PCI0.PEG.VID._PS3' > /proc/acpi/call \ + && exit 0 + ;; + *) echo "Snail: unknown Notebook model: $model"; exit -1 + ;; + esac + + let retry-- + sleep 1 + echo "retry $retry" +done + +exit -1 + diff --git a/usr/local/bin/snail.nv_pwr_on b/usr/local/bin/snail.nv_pwr_on new file mode 100755 index 0000000..b8287f7 --- /dev/null +++ b/usr/local/bin/snail.nv_pwr_on @@ -0,0 +1,95 @@ +#!/bin/sh + +model=`sudo snail.dmidecode` + +let retry=5 +while [ $retry -ne 0 ]; do + + case "$model" in + M11XR2) + echo '\_SB.PCI0.P0P2.PEGP._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + 1015PN) + echo '\_SB.PCI0.P0P4.DGPU.DON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + 1215N) + echo '\_SB.PCI0.P0P4.GFX0._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + K42Jc|K52Jc|N53Jf|N53Jg|N71Jv|N73Jf|P52Jc|PL80Jt|U30Jc|U33Jc|U35Jc|U36Jc|UL80Jt) + echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + N53Sn|U41Sv|N53Sv) + echo '\_SB.PCI0.PEG0.GFX0.DON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + N61Jv|N73Sv) + echo '\_SB.PCI0.PEGR.GFX0.DON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + P31Jg) + echo '\_SB.PCI0.PEG1.GFX0._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + U43Jc) + echo '\_SB.PCI0.RP00.VGA._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + UL30Vt) + echo '\_SB.PCI0.P0P1.VGA._ON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + E6420) + echo '\_SB.PCI0.PEG0.VID._ON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + InspironN5110|XPSL702X) + echo '\_SB.PCI0.PEG0.PEGP._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + Vostro3300|Vostro3500) + echo '\_SB.PCI0.P0P1.PEGP._ON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + XPS15) + echo '\_SB.PCI0.PEG0.PEGP._ON' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + ThinkPadT410) + echo '\_SB.PCI0.PEG.VID._ON' > /proc/acpi/call \ + && echo '\_SB.PCI0.PEG.VID._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + ThinkPadT420) + echo '\_SB.PCI0.PEG.VID._PS0' > /proc/acpi/call \ + && modprobe nvidia \ + && exit 0 + ;; + *) echo "Snail: unknown Notebook model: $model"; exit -1 + ;; + esac + + let retry-- + sleep 1 + echo "retry $retry" +done + +exit -1 + diff --git a/usr/local/bin/snail.nvoff b/usr/local/bin/snail.nvoff new file mode 100755 index 0000000..d979229 --- /dev/null +++ b/usr/local/bin/snail.nvoff @@ -0,0 +1,4 @@ +#!/bin/sh + +sudo /etc/init.d/snail stop + diff --git a/usr/local/bin/snail.nvon b/usr/local/bin/snail.nvon new file mode 100755 index 0000000..c6e3214 --- /dev/null +++ b/usr/local/bin/snail.nvon @@ -0,0 +1,4 @@ +#!/bin/sh + +sudo /etc/init.d/snail start + diff --git a/usr/local/bin/snail.nvrun b/usr/local/bin/snail.nvrun new file mode 100755 index 0000000..3625894 --- /dev/null +++ b/usr/local/bin/snail.nvrun @@ -0,0 +1,16 @@ +#!/bin/sh + +snail.nvstat + +if [ "$?" == 0 ]; then + echo "Running $@ on nVidia Optimus" + LD_PRELOAD="/usr/lib/opengl/nvidia/lib/libGL.so:\ +/usr/lib/opengl/nvidia/lib/libnvidia-tls.so" snail.vglrun -d :1 "$@" + echo "Application $@ was performed on nVidia Optimus" + +else + echo "Running $@ on Intel GPU" + "$@" + echo "Application $@ was performed on Intel GPU" +fi + diff --git a/usr/local/bin/snail.nvstat b/usr/local/bin/snail.nvstat new file mode 100755 index 0000000..e22ed95 --- /dev/null +++ b/usr/local/bin/snail.nvstat @@ -0,0 +1,11 @@ +#!/bin/sh + +[ -f /tmp/.X1-lock ] && pgrep -s `cat /tmp/.X1-lock` &>/dev/null + +let status=$? + +[ 0 -eq $status ] && echo "nVidia graphics is ACTIVE" \ + || echo "nVidia graphics is NOT ACTIVE" + +exit $status + diff --git a/usr/local/bin/snail.vglrun b/usr/local/bin/snail.vglrun new file mode 100755 index 0000000..06effec --- /dev/null +++ b/usr/local/bin/snail.vglrun @@ -0,0 +1,300 @@ +#!/bin/sh + +# Copyright (C)2004 Landmark Graphics Corporation +# Copyright (C)2005 Sun Microsystems, Inc. +# Copyright (C)2009-2011 D. R. Commander +# +# This library is free software and may be redistributed and/or modified under +# the terms of the wxWindows Library License, Version 3.1 or (at your option) +# any later version. The full license is in the LICENSE.txt file included +# with this distribution. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# wxWindows Library License for more details. + +# The interpreter to use (if this script is submitted to N1 Grid Engine): +#$ -S /bin/sh +# +# This allocates a graphics device and passes it in the VGL_DISPLAY +# environment: +#$ -l gfx=1 +# +# Specify other environment variables that N1GE should pass to this script: +#$ -v DISPLAY +#$ -v SSH_CLIENT +#$ -v VGL_CLIENT +#$ -v VGL_COMPRESS +#$ -v VGL_PORT +#$ -v VGL_SSL +#$ -v VGL_GLLIB +#$ -v VGL_X11LIB +#$ -v VGL_GAMMA +#$ -v VGL_PROGRESSIVE +#$ -v VGL_NPROCS + +usage() +{ + echo + echo "Usage: `basename $0` [options] [--] [OpenGL app arguments]" + echo + echo "VirtualGL options (see documentation for a more comprehensive list)" + echo + echo "-c : proxy = Send 3D images uncompressed using X11 Transport" + echo " [default for local X connections]" + echo " jpeg = Compress 3D images using JPEG/send using VGL Transport" + echo " [default for remote X connections]" + echo " rgb = Encode 3D images as RGB/send using VGL Transport" + echo " xv = Encode 3D images as YUV420P/send using XV Transport" + echo " yuv = Encode 3D images as YUV420P/send using the VGL Transport" + echo " and display on the client using X Video" + echo " [If an image transport plugin is being used, then can be any" + echo " number >= 0 (default=0).]" + echo + echo "-nodl : If an app uses dlopen() to explicitly access libGL.so, don't" + echo " force it to open VirtualGL instead (see docs)" + echo + echo "-d : = the X Display to use for 3D rendering [default = :0.0]" + echo + echo "-fps : Limit client/server frame rate to frames/sec" + echo + echo "-gamma : Set gamma correction factor to (see docs)" + echo + echo "-ge : Fool application into thinking that LD_PRELOAD is unset" + echo + echo "-ms : Force VirtualGL to use OpenGL multisampling with " + echo " samples ( = 0 forces multisampling to be disabled)" + echo + echo "-np : Use CPUs to perform image compression [default = 1]" + echo + echo "+/-pr : Enable/disable performance profiling output [default = disabled]" + echo + echo "-q : Compression quality [1 <= <= 100]" + echo " [default = 95 for JPEG/VGL Transport. Has no effect with" + echo " X11 Transport]" + echo + echo "-samp : Chrominance subsampling factor" + echo " = gray, 1x, 2x, 4x" + echo " [default = 1x for JPEG/VGL Transport. Has no effect with" + echo " X11 Transport or RGB encoding]" + echo + echo "+/-s : Enable/disable SSL encryption of VGL Transport or custom" + echo " image transport, if applicable." + echo " [default = disabled. Has no effect on the VGL Transport unless" + echo " VirtualGL was built with OpenSSL support]" + echo + echo "+/-sp : Turn on/off frame spoiling [default = enabled]" + echo + echo "-st : left = Send only left eye buffer of stereo application" + echo " right = Send only right eye buffer of stereo application" + echo " quad = Use quad-buffered stereo if available, otherwise use" + echo " red/cyan (anaglyphic) stereo [default]" + echo " rc = Always use red/cyan (anaglyphic) stereo" + echo + echo "+/-sync : Enable/disable strict 2D/3D synchronization [default = disabled]" + echo + echo "+/-tr : Enable/disable function call tracing (generates a lot of output)" + echo " [default = disabled]" + echo + echo "-trans : Use transport plugin contained in library libvgltrans_.so" + echo + echo "+/-v : Enable/disable verbose VirtualGL messages [default = disabled]" + echo + echo "-64 : (Solaris only) Preload VirtualGL only into 64-bit apps" + echo "-32 : (Solaris only) Preload VirtualGL only into 32-bit apps" + echo + exit $1 +} + +GEOPROBE_USEGLX=1 +export GEOPROBE_USEGLX +PROMAGIC_USEGLX=1 +export PROMAGIC_USEGLX + +if [ "$OPENGL_DEVICE" != "" ]; then + echo "[VGL] NOTICE: The OPENGL_DEVICE environment variable is incompatible with" + echo "[VGL] VirtualGL. Temporarily unsetting this environment variable." +fi +unset OPENGL_DEVICE +export OPENGL_DEVICE + +__VGL_DL=1 +__VGL_GE=0 +__VGL_64=0 +__VGL_32=0 + +while [ $# -gt 0 ] +do + case "$1" in + +sy*) VGL_SYNC=1 ; export VGL_SYNC ;; + -sy*) VGL_SYNC=0 ; export VGL_SYNC ;; + -st*) VGL_STEREO=$2 ; export VGL_STEREO ; shift ;; + +sp*) VGL_SPOIL=1 ; export VGL_SPOIL ;; + -sp*) VGL_SPOIL=0 ; export VGL_SPOIL ;; + -sa*) VGL_SUBSAMP=$2 ; export VGL_SUBSAMP ; shift ;; + -s*) VGL_SSL=0 ; export VGL_SSL ;; + +s*) VGL_SSL=1 ; export VGL_SSL ;; + -prog*) VGL_PROGRESSIVE=0 ; export VGL_PROGRESSIVE ;; + +prog*) VGL_PROGRESSIVE=1 ; export VGL_PROGRESSIVE ;; + -pr*) VGL_PROFILE=0 ; export VGL_PROFILE ;; + +pr*) VGL_PROFILE=1 ; export VGL_PROFILE ;; + -q*) VGL_QUAL=$2 ; export VGL_QUAL ; shift ;; + +de*) VGL_DEBUG=1 ; export VGL_DEBUG ;; + -de*) VGL_DEBUG=0 ; export VGL_DEBUG ;; + -nodl) __VGL_DL=0 ;; + -trans*) VGL_TRANSPORT=$2 ; export VGL_TRANSPORT; shift ;; + +tr*) VGL_TRACE=1 ; export VGL_TRACE ;; + -tr*) VGL_TRACE=0 ; export VGL_TRACE ;; + -d*) VGL_DISPLAY=$2 ; export VGL_DISPLAY ; shift ;; + -cl*) VGL_CLIENT=$2 ; export VGL_CLIENT ; shift ;; + -p*) VGL_PORT=$2 ; export VGL_PORT ; shift ;; + -c*) VGL_COMPRESS=$2 ; export VGL_COMPRESS ; shift ;; + -np*) VGL_NPROCS=$2 ; export VGL_NPROCS ; shift ;; + -gamma) VGL_GAMMA=$2 ; export VGL_GAMMA ; shift ;; + -ge) __VGL_GE=1 ;; + -g*) VGL_GAMMA=0 ; export VGL_GAMMA ;; + +g*) VGL_GAMMA=1 ; export VGL_GAMMA ;; + -v*) VGL_VERBOSE=0 ; export VGL_VERBOSE ;; + +v*) VGL_VERBOSE=1 ; export VGL_VERBOSE ;; + -fps) VGL_FPS=$2 ; export VGL_FPS ; shift ;; + -ms) VGL_SAMPLES=$2 ; export VGL_SAMPLES ; shift ;; + -ld) LD_LIBRARY_PATH=$2:$LD_LIBRARY_PATH ; + export LD_LIBRARY_PATH ; shift ;; + -64) __VGL_64=1; __VGL_32=0 ;; + -32) __VGL_32=1; __VGL_64=0 ;; + -h) usage 0 ;; + --help) usage 0 ;; + --) shift ; break ;; + -*) usage 1 ;; + *) break ;; + esac + shift +done +if [ $# -eq 0 ] +then + usage 0 +fi + +if [ -r /etc/opt/VirtualGL/vgl_xauth_key ]; then + XAUTH=xauth + if [ -x /usr/X11R6/bin/xauth ]; then + XAUTH=/usr/X11R6/bin/xauth + fi + if [ -x /usr/openwin/bin/xauth ]; then + XAUTH=/usr/openwin/bin/xauth + fi + $XAUTH merge /etc/opt/VirtualGL/vgl_xauth_key +fi + +SSH_IP=`echo $SSH_CLIENT | cut -d' ' -f1 | cut -d: -f4` +if [ -z "$DISPLAY" ]; then + if [ ! -z "$SSH_IP" ]; then + DISPLAY=$SSH_IP:0.0 + export DISPLAY + echo "[VGL] NOTICE: Automatically setting the DISPLAY environment variable to" + echo "[VGL] $DISPLAY, based on the IP address of your SSh client." + fi +else + DISPLAYHOST=`echo $DISPLAY | cut -d: -f1` + if [ "$DISPLAYHOST" = "localhost" -o "$DISPLAYHOST" = "`hostname`" ]; then + if [ ! -z "$SSH_IP" -a -z "$VGL_CLIENT" -a -z "$RRCLIENT" ]; then + VGL_CLIENT=$SSH_IP:0.0 + export VGL_CLIENT + echo "[VGL] NOTICE: Automatically setting VGL_CLIENT environment variable to" + echo "[VGL] $SSH_IP, the IP address of your SSh client." + fi + fi +fi + +case `uname -s` in + +SunOS) + +if [ -z "$FAKERLIB" ]; then +FAKERLIB=librrfaker.so +if [ -f /opt/VirtualGL/lib/64/librrfaker.so ] +then + FAKERLIB=/opt/VirtualGL/lib/64/librrfaker.so +fi +fi +export FAKERLIB +if [ -z "$FAKERLIB32" ]; then +FAKERLIB32=librrfaker.so +if [ -f /opt/VirtualGL/lib/librrfaker.so ] +then + FAKERLIB32=/opt/VirtualGL/lib/librrfaker.so +fi +fi +export FAKERLIB32 +if [ $__VGL_64 -eq 0 ]; then + if [ -z "$LD_PRELOAD_32" ]; then + LD_PRELOAD_32=$FAKERLIB32 + else + LD_PRELOAD_32=$FAKERLIB32:$LD_PRELOAD_32 + fi + if [ $__VGL_DL -eq 1 ]; then + if [ -f /opt/VirtualGL/lib/libdlfaker.so ] + then + LD_PRELOAD_32=/opt/VirtualGL/lib/libdlfaker.so:$LD_PRELOAD_32 + else + LD_PRELOAD_32=libdlfaker.so:$LD_PRELOAD_32 + fi + fi + if [ $__VGL_GE -eq 1 ]; then + if [ -f /opt/VirtualGL/lib/libgefaker.so ] + then + LD_PRELOAD_32=/opt/VirtualGL/lib/libgefaker.so:$LD_PRELOAD_32 + else + LD_PRELOAD_32=libgefaker.so:$LD_PRELOAD_32 + fi + fi + export LD_PRELOAD_32 +fi +if [ $__VGL_32 -eq 0 ]; then + if [ -z "$LD_PRELOAD_64" ]; then + LD_PRELOAD_64=$FAKERLIB + else + LD_PRELOAD_64=$FAKERLIB:$LD_PRELOAD_64 + fi + if [ $__VGL_DL -eq 1 ]; then + if [ -f /opt/VirtualGL/lib/64/libdlfaker.so ] + then + LD_PRELOAD_64=/opt/VirtualGL/lib/64/libdlfaker.so:$LD_PRELOAD_64 + else + LD_PRELOAD_64=libdlfaker.so:$LD_PRELOAD_64 + fi + fi + if [ $__VGL_GE -eq 1 ]; then + if [ -f /opt/VirtualGL/lib/64/libgefaker.so ] + then + LD_PRELOAD_64=/opt/VirtualGL/lib/64/libgefaker.so:$LD_PRELOAD_64 + else + LD_PRELOAD_64=libgefaker.so:$LD_PRELOAD_64 + fi + fi + export LD_PRELOAD_64 +fi +exec ${1+"$@"} + +;; + +*) + +if [ -z "$LD_PRELOAD" ]; then + LD_PRELOAD=librrfaker.so +else + LD_PRELOAD=librrfaker.so:$LD_PRELOAD +fi +if [ $__VGL_DL -eq 1 ]; then + LD_PRELOAD=libdlfaker.so:$LD_PRELOAD +fi +if [ $__VGL_GE -eq 1 ]; then + LD_PRELOAD=libgefaker.so:$LD_PRELOAD +fi +export LD_PRELOAD +exec ${1+"$@"} + +;; + +esac diff --git a/usr/local/lib64/libdlfaker.so b/usr/local/lib64/libdlfaker.so new file mode 100755 index 0000000..182b0f2 Binary files /dev/null and b/usr/local/lib64/libdlfaker.so differ diff --git a/usr/local/lib64/libgefaker.so b/usr/local/lib64/libgefaker.so new file mode 100755 index 0000000..6ff95f5 Binary files /dev/null and b/usr/local/lib64/libgefaker.so differ diff --git a/usr/local/lib64/librrfaker.so b/usr/local/lib64/librrfaker.so new file mode 100755 index 0000000..5fc4014 Binary files /dev/null and b/usr/local/lib64/librrfaker.so differ diff --git a/usr/local/lib64/snail/extensions b/usr/local/lib64/snail/extensions new file mode 120000 index 0000000..a9b7025 --- /dev/null +++ b/usr/local/lib64/snail/extensions @@ -0,0 +1 @@ +/usr/lib/opengl/nvidia/extensions \ No newline at end of file diff --git a/usr/local/lib64/snail/modules b/usr/local/lib64/snail/modules new file mode 120000 index 0000000..0351950 --- /dev/null +++ b/usr/local/lib64/snail/modules @@ -0,0 +1 @@ +/usr/lib/xorg/modules \ No newline at end of file diff --git a/usr/local/sbin/snail.dmidecode b/usr/local/sbin/snail.dmidecode new file mode 100755 index 0000000..fd8af70 --- /dev/null +++ b/usr/local/sbin/snail.dmidecode @@ -0,0 +1,4 @@ +#!/bin/sh + +dmidecode $@ -s system-product-name + diff --git a/usr/local/sbin/snail.install b/usr/local/sbin/snail.install new file mode 100755 index 0000000..2f6511f --- /dev/null +++ b/usr/local/sbin/snail.install @@ -0,0 +1,27 @@ +#!/bin/sh + +PREFIX=/usr/local + +# Tell the system to use xorg-x11 OpenGL libraries and nVidia GLX extensions +eselect opengl set xorg-x11 +for arch in 32bit 64bit; do for chip in i915 i965 r300 r600 sw; do sudo eselect mesa set $arch $chip classic &>/dev/null; done; done + +# Create backups of original xorg.conf.* files and replacing with snail's versions +[[ -f /etc/X11/xorg.conf && ! -f /etc/X11/xorg.conf.snail-bkp ]] && mv /etc/X11/xorg.conf /etc/X11/xorg.conf.snail-bkp +[[ -f /etc/X11/xorg.conf.intel && ! -f /etc/X11/xorg.conf.intel.snail-bkp ]] && mv /etc/X11/xorg.conf.intel /etc/X11/xorg.conf.intel.snail-bkp +[[ -f /etc/X11/xorg.conf.nvidia && ! -f /etc/X11/xorg.conf.nvidia.snail-bkp ]] && mv /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf.nvidia.snail-bkp +cp -f /etc/X11/xorg.conf.intel.snail /etc/X11/xorg.conf.intel +cp -f /etc/X11/xorg.conf.nvidia.snail /etc/X11/xorg.conf.nvidia +ln -sf xorg.conf.intel /etc/X11/xorg.conf + +# Recognize BusID of both chips and set it in xorg.conf.* files +BusIDIntel="PCI:`lspci | grep VGA | grep Intel | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`" +BusIDNvidia="PCI:`lspci | grep VGA | grep nVidia | cut -d" " -f1 | sed 's~\.~\:~g ; s~0\([0-9]\)~\1~g'`" +sed -i "s~BusIDIntel~$BusIDIntel~" /etc/X11/xorg.conf.intel +sed -i "s~BusIDNvidia~$BusIDNvidia~" /etc/X11/xorg.conf.nvidia + +# Allow in sudo for %video group to start/stop second X-server with nVidia card and run snail.dmidecode +sed -i '/snail/d' /etc/sudoers +sudoers_lines=`wc -l /etc/sudoers | cut -d" " -f1` +sed -i "${sudoers_lines}a#snail:\n#snail: Allow %video group to start/stop second X-server with nVidia card\n#snail:\n%video ALL= NOPASSWD: /etc/init.d/snail start\n%video ALL= NOPASSWD: /etc/init.d/snail stop\n%video ALL= NOPASSWD: /usr/local/sbin/snail.dmidecode" /etc/sudoers + diff --git a/usr/local/sbin/snail.uninstall b/usr/local/sbin/snail.uninstall new file mode 100755 index 0000000..43bdcbd --- /dev/null +++ b/usr/local/sbin/snail.uninstall @@ -0,0 +1,18 @@ +#!/bin/sh + +# Tell the system to use both xorg-x11 OpenGL and GLX libraries +eselect opengl set xorg-x11 + +# Restore xorg.conf.* files from backups +[ -f /etc/X11/xorg.conf.snail-bkp ] && rm -f /etc/X11/xorg.conf && mv /etc/X11/xorg.conf.snail-bkp /etc/X11/xorg.conf +[ -f /etc/X11/xorg.conf.intel.snail-bkp ] && rm -f /etc/X11/xorg.conf.intel && mv /etc/X11/xorg.conf.intel.snail-bkp /etc/X11/xorg.conf.intel +[ -f /etc/X11/xorg.conf.nvidia.snail-bkp ] && rm -f /etc/X11/xorg.conf.nvidia && mv /etc/X11/xorg.conf.nvidia.snail-bkp /etc/X11/xorg.conf.nvidia + +# Remove backup files +for f in "" .intel .nvidia ; do + rm -f /etc/X11/xorg.conf${f}.snail-bkp +done + +# Remove records in sudoers +sed -i '/snail/d' /etc/sudoers +