home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / xresprobe / lcdsize.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-07-17  |  4.5 KB  |  117 lines

  1. #!/bin/sh
  2. # usage: lcdsize.sh driver logfile [stdout]
  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;
  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. getres () {
  23.   RESLINE="$(egrep "$EGREPLINE" "$LOGFILE" | head -1)"
  24.   RES="$(echo "$RESLINE" | sed -e "$SEDLINE")"
  25. }
  26.  
  27. DRIVER="$1"
  28. LOGFILE="$2"
  29. # stdout is, for now, unused
  30. STDOUT="$3"
  31.  
  32. if [ -z "$DRIVER" -o -z "$LOGFILE" ]; then
  33.   echo "Driver name and logfile must be specified on the command line."
  34.   exit 1
  35. fi
  36.  
  37. # EGREPLINE must pull out only one line, which contains the res, from egrep.
  38. # SEDLINE must print the resolution from that line.
  39.  
  40. if [ "$DRIVER" = "ati" -o "$DRIVER" = "atimisc" -o "$DRIVER" = "r128" -o \
  41.      "$DRIVER" = "radeon" ]; then
  42.   EGREPLINE="\(--\) ATI\(.*\): .* panel \(ID .*\) detected."
  43.   SEDLINE="s/(--) ATI([^)]*): \([^ ]*\) panel (ID [^)]*) detected./\1/;"
  44.   getres
  45.   if [ -z "$RES" ]; then
  46.     EGREPLINE="\(II\) RADEON\(.*\): Panel [Ss]ize .*from .*: .*"
  47.     SEDLINE="s/(II) RADEON([^)]*): Panel [Ss]ize .*from [^:]*: \(.*\)/\1/;"
  48.     getres
  49.   fi
  50.   if [ -z "$RES" ]; then
  51.     EGREPLINE="\(WW\) RADEON\(.*\): Panel size .*x.* is derived, this may not be correct."
  52.     SEDLINE="s/(WW) RADEON([^)]*): Panel size \([^x]*\)x\([^ ]*\) is derived, this may not be correct./\1x\2/;"
  53.     getres
  54.   fi
  55.   if [ -z "$RES" ]; then
  56.     EGREPLINE="\(II\) R128\(.*\): Panel size: .*x.*"
  57.     SEDLINE="s/(II) R128([^)]*): Panel size: \(.*\)/\1/;"
  58.     getres
  59.   fi
  60. elif [ "$DRIVER" = "i810" ]; then
  61.   EGREPLINE="\(II\) I810\(.*\): Size of device LFP \(local flat panel\) is .* x .*"
  62.   SEDLINE="s/(II) I810([^)]*): Size of device LFP (local flat panel) is \([^ ]*\) x \([^ ]*\)/\1x\2/;"
  63.   getres
  64. elif [ "$DRIVER" = "savage" ]; then
  65.   EGREPLINE="\(--\) SAVAGE\(.*\): .*.* .* LCD panel detected.*"
  66.   SEDLINE="s/(--) SAVAGE([^)]*): \([^x]*\)x\([^x]*\) [^ ]* LCD panel detected.*$/\1x\2/;"
  67.   getres
  68.   # don't even ask.  ubuntu #15231.
  69.   RES="$(echo "$RES" | sed -e 's/1408x1050/1400x1050/;')"
  70. elif [ "$DRIVER" = "neomagic" ]; then
  71.   EGREPLINE="\(--\) NEOMAGIC\(.*\): Panel is a .*x.* .* .* display"
  72.   SEDLINE="s/(--) NEOMAGIC(.*): Panel is a \([^x]*\)x\([^ ]*\) [^ ]* .* display/\1x\2/;"
  73.   getres
  74. elif [ "$DRIVER" = "nv" ]; then
  75.   # the nv driver would ideally tell us this
  76.   # ... and it does, when backported
  77.   EGREPLINE="\(--\) NV\(.*\): Panel size is .* x .*"
  78.   SEDLINE="s/(--) NV([^)]*): Panel size is \([^ ]*\) x \(.*\)/\1x\2/;"
  79.   getres
  80.   if [ -z "$RES" ]; then
  81.     EGREPLINE="\(--\) NV\(.*\): Virtual size is .*x.* \(pitch .*\)"
  82.     SEDLINE="s/(--) NV([^)]*): Virtual size is \([^x]*\)x\([^ ]*\) (pitch .*)/\1x\2/;"
  83.     getres
  84.   fi
  85. elif [ "$DRIVER" = "siliconmotion" ]; then
  86.   EGREPLINE="\(II\) Silicon MotionDetected panel size via BIOS: .* x .*"
  87.   SEDLINE="s/(II) Silicon MotionDetected panel size via BIOS: \([^ ]*\) x \([^ ]*\)/\1x\2/;"
  88.   getres
  89.   if [ -z "$RES" ]; then
  90.     EGREPLINE="\(II\) Silicon Motion.* Panel Size = .*x.*"
  91.     SEDLINE="s/(II) Silicon Motion[^ ]* Panel Size = \([^x]*\)x\([^ ]*\)/\1x\2/;"
  92.     getres
  93.   fi
  94. elif [ "$DRIVER" = "trident" ]; then
  95.   EGREPLINE="\(--\) TRIDENT\(.*\): .* Panel .*x.* found"
  96.   SEDLINE="s/(--) TRIDENT([^)]*): [^ ]* Panel \([^x]*\)x\([^ ]*\) found/\1x\2/;"
  97.   getres
  98. elif [ "$DRIVER" = "via" ]; then
  99.   EGREPLINE="\(II\) VIA\(.*\): ViaPanelGetIndex: index: .* (.*x.*)"
  100.   SEDLINE="s/(II) VIA([^)]*): ViaPanelGetIndex: index: [^ ]* (\([^x]*\)x\([^)]*\))/\1x\2/;"
  101.   getres
  102.   if [ -z "$RES" ]; then
  103.     EGREPLINE="\(II\) VIA\(.*\): Selected Panel Size is .*x.*"
  104.     SEDLINE="s/(II) VIA([^)]*): Selected Panel Size is \([^x]*\)x\([^ ]*\)/\1x\2/;"
  105.     getres
  106.   fi
  107. elif [ "$DRIVER" = "chips" ]; then
  108.   EGREPLINE="\(--\) CHIPS\(.*\): Display Size: x=.*; y=.*"
  109.   SEDLINE="s/(--) CHIPS([^)]*): Display Size: x=\([^;]*\); y=\([^ ]*\)/\1x\2/;"
  110.   getres
  111. else
  112.   exit 1
  113. fi
  114.  
  115. echo "$RES"
  116.