#!/bin/bash # # shell-tool for accessing nvidia-card-options # # Copyright (c) 2003 Mathias Gumz # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. OS="" SHELL="sh" ACTION="detect" CARD_ID="" CARD_NAME="none" CARD_FSAA="0" CARD_FSSA_MED="0" CARD_FSAA_BEST="0" CARD_AISO="0" CARD_AISO_MED="0" CARD_AISO_BEST="0" FSAA="" AISO="" # # # display_usage() { cat << EOF NAME nvshell - fast access to nvidia-card options SYNOPSIS nvshell [-hHdDi] [-f mode] [-a mode] [-c id] [-s shell] OPTIONS -h usage -H big help -d detect card -D driver version -c id set cardid -C list cards -f mode set fsaa mode, 0-5,m,b -F list fsaa modes -a mode set aiso mode, 0-2,m,b -A list aiso modes -s shell set shellmode (sh, csh, tcsh etc) EOF } display_help() { display_usage cat << EOF TAGS m stands for 'medium' b stands for 'best' TIPS to set for example best antialiasing mode on a couple of machines in the lan, add this two lines to your shell-configfiles: bash: nvshell -a b nvshell -f b csh: nvshell -s csh -a b nvshell -s csh -f b AUTHOR mathias gumz EOF } print_fsaa_db() { cat << EOF na|na|na|na|na|na FSAA disabled|FSAA disabled|FSAA disabled|1.5 x 1.5 Supersampling|2 x 2 Supersampling|FSAA disabled FSAA disabled|2x Bilinear Multisampling|2x Quincunx Multisampling|FSAA disabled|4x Bilinear Multisampling|4x Gaussian Multisampling FSAA disabled|2x Bilinear Multisampling|2x Quincunx Multisampling|FSAA disabled|2 x 2 Supersampling|FSAA disabled FSAA disabled|2x Bilinear Multisampling|2x Quincunx Multisampling|FSAA disabled|4x Bilinear Multisampling|4x Gaussian Multisampling EOF } print_aiso_db() { cat << EOF na|na|na|na no anisotropic filtering|enable automatic anisotropic filtering|na|na no anisotropic filtering|low anisotropic filtering|medium anisotropic filtering|maximum anisotropic filtering EOF } # # cardname|pci-id|fsaa-db-line|med|best|aiso-db-line|med|best # print_db() { cat << EOF RIVA TNT |0x0020|0|0|0|0|0|0 RIVA TNT2 |0x0028|0|0|0|0|0|0 RIVA TNT2 Ultra |0x0029|0|0|0|0|0|0 Vanta |0x002C|0|0|0|0|0|0 RIVA TNT2 Model 64 |0x002D|0|0|0|0|0|0 Aladdin TNT2 |0x00A0|0|0|0|0|0|0 GeForce 256 |0x0100|1|3|4|1|0|1 GeForce DDR |0x0101|1|3|4|1|0|1 Quadro |0x0103|1|3|4|1|0|1 GeForce2 MX/MX 400 |0x0110|1|3|4|1|0|1 GeForce2 MX 100/200 |0x0111|1|3|4|1|0|1 GeForce2 Go |0x0112|1|3|4|1|0|1 Quadro2 MXR/EX/Go |0x0113|1|3|4|1|0|1 GeForce2 GTS |0x0150|1|3|4|1|0|1 GeForce2 Ti |0x0151|1|3|4|1|0|1 GeForce2 Ultra |0x0152|1|3|4|1|0|1 Quadro2 Pro |0x0153|1|3|4|1|0|1 GeForce4 MX 460 |0x0170|3|1|4|1|0|1 GeForce4 MX 440 |0x0171|3|1|4|1|0|1 GeForce4 MX 420 |0x0172|3|1|4|1|0|1 GeForce4 MX 440-SE |0x0173|3|1|4|1|0|1 GeForce4 440 Go |0x0174|3|1|4|2|1|2 GeForce4 420 Go |0x0175|3|1|4|2|1|2 GeForce4 420 Go 32M |0x0176|3|1|4|2|1|2 GeForce4 460 Go |0x0177|3|1|4|2|1|2 Quadro4 550 XGL |0x0178|3|1|4|2|1|2 GeForce4 440 Go 64M |0x0179|3|1|4|2|1|2 Quadro4 NVS |0x017A|3|1|4|2|1|2 Quadro4 500 GoGL |0x017C|3|1|4|2|1|2 GeForce4 410 Go 16M |0x017D|3|1|4|2|0|1 GeForce4 MX 440 with AGP8X |0x0181|3|1|4|2|0|1 GeForce4 MX 440SE with AGP8X|0x0182|3|1|4|1|0|1 GeForce4 MX 420 with AGP8X |0x0183|3|1|4|1|0|1 GeForce4 448 Go |0x0186|3|1|4|2|2|3 GeForce4 488 Go |0x0187|3|1|4|2|2|3 Quadro4 580 XGL |0x0188|3|1|4|2|2|3 Quadro4 280 NVS |0x018A|3|1|4|2|2|3 Quadro4 380 XGL |0x018B|3|1|4|2|2|3 GeForce2 Integrated GPU |0x01A0|1|3|4|2|2|3 GeForce4 MX Integrated GPU |0x01F0|3|1|4|1|0|1 GeForce3 |0x0200|2|1|5|2|2|3 GeForce3 Ti 200 |0x0201|2|1|5|2|2|3 GeForce3 Ti 500 |0x0202|2|1|5|2|2|3 Quadro DCC |0x0203|2|1|5|2|2|3 GeForce4 Ti 4600 |0x0250|2|1|5|2|2|3 GeForce4 Ti 4400 |0x0251|2|1|5|2|2|3 NV25 |0x0252|2|1|5|2|2|3 GeForce4 Ti 4200 |0x0253|2|1|5|2|2|3 Quadro4 900 XGL |0x0258|2|1|5|2|2|3 Quadro4 750 XGL |0x0259|2|1|5|2|2|3 Quadro4 700 XGL |0x025B|2|1|5|2|2|3 GeForce4 Ti 4800 |0x0280|2|1|5|2|2|3 GeForce4 Ti 4200 with AGP8X |0x0281|2|1|5|2|2|3 GeForce4 Ti 4800 SE |0x0282|2|1|5|2|2|3 GeForce4 4200 Go |0x0286|2|1|5|2|2|3 Quadro4 980 XGL |0x0288|2|1|5|2|2|3 Quadro4 780 XGL |0x0289|2|1|5|2|2|3 Quadro4 700 GoGL |0x028C|2|1|5|2|2|3 GeForce FX 5800 Ultra |0x0301|4|2|5|2|2|3 GeForce FX 5800 |0x0302|4|2|5|2|2|3 Quadro FX 2000 |0x0308|4|2|5|2|2|3 Quadro FX 1000 |0x0309|4|2|5|2|2|3 ICE FX 2000 |0x030A|4|2|5|2|2|3 GeForce FX 5600 Ultra |0x0311|4|2|5|2|2|3 GeForce FX 5600 |0x0312|4|2|5|2|2|3 NV31 |0x0313|4|2|5|2|2|3 GeForce FX 5600SE |0x0314|4|2|5|2|2|3 NV31M |0x0316|4|2|5|2|2|3 NV31MPro |0x0317|4|2|5|2|2|3 GeForce FX Go5600 |0x031A|4|2|5|2|2|3 GeForce FX Go5650 |0x031B|4|2|5|2|2|3 Quadro FX Go700 |0x031C|4|2|5|2|2|3 NV31GLM |0x031D|4|2|5|2|2|3 NV31GLM Pro |0x031E|4|2|5|2|2|3 NV31GLM Pro |0x031F|4|2|5|2|2|3 GeForce FX 5200 Ultra |0x0321|4|2|5|2|2|3 GeForce FX 5200 |0x0322|4|2|5|2|2|3 GeForce FX 5200SE |0x0323|4|2|5|2|2|3 GeForce FX Go5200 |0x0324|4|2|5|2|2|3 GeForce FX Go5250 |0x0325|4|2|5|2|2|3 GeForce FX Go5200 |0x0328|4|2|5|2|2|3 NV34GL |0x032A|4|2|5|2|2|3 Quadro FX 500 |0x032B|4|2|5|2|2|3 GeForce FX Go5100 |0x032D|4|2|5|2|2|3 NV34GL |0x032F|4|2|5|2|2|3 GeForce FX 5900 Ultra |0x0330|4|2|5|2|2|3 GeForce FX 5900 |0x0331|4|2|5|2|2|3 NV35 |0x0332|4|2|5|2|2|3 EOF } detect_card() { case "$OS" in linux) CARD_ID=`sed -n /10de/p /proc/bus/pci/devices | cut -f 2 | sed 's/10de/0x/g'` ;; freebsd) CARD_ID=`pciconf -l | sed -n /10de/p | sed -e 's/^.*chip=//g;s/10de.*//g'` ;; esac } detect_version() { case "$OS" in linux) sed 1q /proc/driver/nvidia/version | awk '{ print $9; };' ;; freebsd);; esac } get_entry() { if [ -z "$CARD_ID" ]; then detect_card; fi entry=`print_db | sed -n /$CARD_ID/p` CARD_NAME=`echo $entry | cut -d '|' -f 1` CARD_FSAA=`echo $entry | cut -d '|' -f 3` CARD_FSAA_MED=`echo $entry | cut -d '|' -f 4` CARD_FSAA_BEST=`echo $entry | cut -d '|' -f 5` CARD_AISO=`echo $entry | cut -d '|' -f 6` CARD_AISO_MED=`echo $entry | cut -d '|' -f 7` CARD_AISO_BEST=`echo $entry | cut -d '|' -f 8` } display_fsaa() { for i in 0 1 2 3 4 5 do echo -n " $i " if [ "$CARD_FSAA_MED" == "$i" ]; then echo -n "m"; else echo -n " "; fi if [ "$CARD_FSAA_BEST" == "$i" ]; then echo -n "b "; else echo -n " "; fi print_fsaa_db | sed $((CARD_FSAA+1))'!d' | cut -d '|' -f $((i + 1)) done } display_aiso() { for i in 0 1 2 3 do echo -n " $i " if [ "$CARD_AISO_MED" == "$i" ]; then echo -n "m"; else echo -n " "; fi if [ "$CARD_AISO_BEST" == "$i" ]; then echo -n "b "; else echo -n " "; fi print_aiso_db | sed $((CARD_AISO+1))'!d' | cut -d '|' -f $((i + 1)) done } # # # main stuff # while getopts ":hHc:CdDf:Fa:Ais:o:" opts do case "$opts" in h ) display_usage; exit 0;; H ) display_help; exit 0;; i ) ACTION="info";; d ) ACTION="detect";; D ) ACTION="driver";; f ) ACTION="set";FSAA="$OPTARG";; a ) ACTION="set";AISO="$OPTARG";; c ) CARD_ID="$OPTARG";; F ) ACTION="list_fsaa";; A ) ACTION="list_aiso";; C ) ACTION="list_cards";; s ) SHELL="$OPTARG";; o ) OS="$OPTARG";; esac done # detect os if [ -z "$OS" ]; then OS=`uname | tr [:upper:] [:lower:]`; fi # do evil stuff case "$ACTION" in detect) get_entry echo " $CARD_ID | $CARD_NAME" ;; driver) echo " driver version: $(detect_version)" ;; info) get_entry echo " $CARD_ID | $CARD_NAME" echo "-----------------------------------------" echo " __GL_FSAA = $__GL_FSAA" echo " __GL_DEFAULT_LOG_ANISO = $__GL_DEFAULT_LOG_ANISO" echo "-----------------------------------------" echo -e " fsaa-modes:" display_fsaa echo -e "\n aniso-modes" display_aiso ;; list_cards) print_db #| cut -d '|' -f 1,2;; ;; list_fsaa) get_entry display_fsaa ;; list_aiso) get_entry display_aiso ;; set) get_entry if [ -n "$FSAA" ]; then case "$FSAA" in m | med ) FSAA=$CARD_FSAA_MED;; b | best ) FSAA=$CARD_FSAA_BEST;; esac case "$SHELL" in sh | bash | ksh ) echo -n "export __GL_FSAA=$FSAA;";; csh | tcsh ) echo -n "setenv __GL_FSAA $FSAA;";; esac fi if [ -n "$AISO" ]; then case "$AISO" in m | med ) AISO=$CARD_AISO_MED;; b | best ) AISO=$CARD_AISO_BEST;; esac case "$SHELL" in sh | bash | ksh ) echo -n "export __GL_DEFAULT_LOG_ANISO=$AISO;";; csh | tcsh ) echo -n "setenv __GL_DEFAULT_LOG_ANISO $AISO;";; esac fi ;; esac