home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / sbin / xresprobe < prev    next >
Encoding:
Text File  |  2007-03-17  |  4.3 KB  |  171 lines

  1. #!/bin/sh
  2. # Usage: xresprobe driver [screentype]
  3. # Copyright (C) 2004 Canonical Ltd
  4. # Author: Daniel Stone <daniel.stone@ubuntu.com>
  5. #  This program is free software; you can redistribute it and/or modify
  6. #  it under the terms of the GNU General Public License as published by
  7. #  the Free Software Foundation; version 2 of the License.
  8. #
  9. #  This program is distributed in the hope that it will be useful,
  10. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. #  GNU General Public License for more details.
  13. #
  14. #  You should have received a copy of the GNU General Public License with
  15. #  the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL-2;
  16. #  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  17. #  Suite 330, Boston, MA  02111-1307  USA
  18. #
  19. # On Debian systems, the complete text of the GNU General Public
  20. # License, version 2, can be found in /usr/share/common-licenses/GPL-2.
  21.  
  22. DATADIR="/usr/share/xresprobe"
  23.  
  24. DRIVER="$1"
  25. SCREENTYPE="$2"
  26. RETCODE=0
  27.  
  28. if [ -z "$DRIVER" ]; then
  29.   echo "Driver must be specified."
  30.   exit 1
  31. fi
  32.  
  33. if [ -n "$SCREENTYPE" ]; then
  34.   if [ "$SCREENTYPE" = "laptop" ]; then
  35.     LAPTOP="yes"
  36.   elif [ "$SCREENTYPE" = "crt" ]; then
  37.     DDC="yes"
  38.   elif [ "$SCREENTYPE" = "lcd" ]; then
  39.     DDC="yes"
  40.   fi
  41. else
  42.   if which laptop-detect >/dev/null 2>&1; then
  43.     if laptop-detect >/dev/null 2>&1; then
  44.       LAPTOP="yes"
  45.     else
  46.       DDC="yes"
  47.     fi
  48.   else
  49.     echo "laptop-detect must be installed for xresprobe to work properly. If"
  50.     echo "you really want to continue without it, call xresprobe like:"
  51.     echo "$0 drivername [laptop|crt|lcd]"
  52.     echo
  53.     echo "Note that laptop LCDs are different from standard desktop LCDs, so"
  54.     echo "be careful how you call it."
  55.   fi
  56. fi
  57.  
  58. if [ -n "$XRESPROBE_DEBUG" ]; then
  59.   echo "laptop: $LAPTOP; ddc: $DDC" >&2
  60. fi
  61.  
  62. if [ -n "$XRESPROBE_RIG" ]; then
  63.   if [ -n "$XRESPROBE_DEBUG" ]; then
  64.     echo "xresprobe: rigging results for $XRESPROBE_RIG" >&2
  65.   fi
  66.   exec "$DATADIR/rigprobe.sh" $DRIVER $SCREENTYPE $LAPTOP
  67. fi
  68.  
  69. doddc() {
  70.   if [ -n "$XRESPROBE_DEBUG" ]; then
  71.     echo "attempting DDC detection" >&2
  72.   fi
  73.   DDCOUT="$("$DATADIR/ddcprobe.sh")"
  74.   RETCODE="$?"
  75.   RES="$(echo "$DDCOUT" | grep "^res:" | sed -e 's/^res: *//;')"
  76.   IDENTIFIER="$(echo "$DDCOUT" | grep "^name:" | sed -e 's/^name: *//;')"
  77.   FREQ="$(echo "$DDCOUT" | grep "^freq:" | sed -e 's/^freq: *//;')"
  78.   DISPTYPE="$(echo "$DDCOUT" | grep "^disptype:" | sed -e 's/^disptype: *//;')"
  79.  
  80.   # well, not necessarily, but it's a pretty good guess
  81.   if [ -n "$DISPTYPE" ] && [ "$DISPTYPE" = "lcd" ]; then
  82.     DISPTYPE="lcd/tmds"
  83.   fi
  84. }
  85.  
  86. forkx() {
  87.   if [ -z "$FORKEDX" ]; then
  88.     if [ -n "$XRESPROBE_DEBUG" ]; then
  89.       echo "forking Xorg" >&2
  90.     fi
  91.     XPROBEDIR="$("$DATADIR/xprobe.sh" "$DRIVER")"
  92.     RETCODE="$?"
  93.     LOGFILE="$XPROBEDIR/xorg.log"
  94.     FORKEDX="yes"
  95.   else
  96.     if [ -n "$XRESPROBE_DEBUG" ]; then
  97.       echo "X has already been forked; not reforking" >&2
  98.     fi
  99.   fi
  100. }
  101.  
  102. cleanx() {
  103.   if [ -n "$FORKEDX" ]; then
  104.     if [ -n "$XRESPROBE_DEBUG" ]; then
  105.       echo "not removing temporary xprobe directory $XPROBEDIR; please do this \
  106.             by hand" >&2
  107.     else
  108.       rm -rf "$XPROBEDIR"
  109.     fi
  110.     FORKEDX=""
  111.   else
  112.     if [ -n "$XRESPROBE_DEBUG" ]; then
  113.       echo "not cleaning up after Xorg; not forked" >&2
  114.     fi
  115.   fi
  116. }
  117.  
  118. doprobe() {
  119.   if [ -n "$XRESPROBE_DEBUG" ]; then
  120.     echo "attempting an X probe" >&2
  121.   fi
  122.   forkx
  123.   RES="$("$DATADIR/lcdsize.sh" $DRIVER $LOGFILE)"
  124. }
  125.  
  126. dodepthcheck() {
  127.   if [ -n "$XRESPROBE_DEBUG" ]; then
  128.     echo "checking for broken i8xx BIOS with no 24bpp modes" >&2
  129.   fi
  130.   forkx
  131.   FORCEDEPTH="$("$DATADIR/bitdepth.sh" $DRIVER $LOGFILE)"
  132. }
  133.  
  134. if [ "$DRIVER" = "i810" ]; then
  135.   dodepthcheck
  136. fi
  137.  
  138. if [ "x$LAPTOP" = "xyes" ]; then
  139.   if [ "$(uname -m)" = "ppc" ] || [ "$(uname -m)" = "ppc64" ]; then
  140.     doddc
  141.   fi
  142.   if [ -z "$RES" ]; then
  143.     doprobe
  144.   fi
  145.   DISPTYPE="lcd/lvds"
  146. elif [ "x$DDC" = "xyes" ]; then
  147.   doddc
  148. fi
  149.  
  150. if [ -n "$XRESPROBE_DEBUG" ]; then
  151.   echo "id: $IDENTIFIER" >&2
  152.   echo "res: $RES" >&2
  153.   echo "freq: $FREQ" >&2
  154.   echo "disptype: $DISPTYPE" >&2
  155.   if [ -n "$FORCEDEPTH" ]; then
  156.     echo "depth: $FORCEDEPTH" >&2
  157.   fi
  158. fi
  159.  
  160. echo "id: $IDENTIFIER"
  161. echo "res: $RES"
  162. echo "freq: $FREQ"
  163. echo "disptype: $DISPTYPE"
  164. if [ -n "$FORCEDEPTH" ]; then
  165.   echo "depth: $FORCEDEPTH"
  166. fi
  167.  
  168. cleanx
  169. exit $RETCODE
  170.