summaryrefslogblamecommitdiffstats
path: root/initramfs/initrd-stuff/bin/xconfig
blob: 7f465746c980e29d0f2e533597763d6971c844e6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                          


                                                                        


                                                                             


             
                                                        







                                                         
                                          



                              
                                                       
      
                      



                                            
                         
      
                  
                                                       



                                                 
                         
      
                     
                                                                  
    

                                                                          
                              
                     


           














                                                                             


                                                                           
      

               






                                       







                         

                    






                                          
                                              





















































                                                                   
                              






                                                   

                                                                         





                                               

                                                                             

                                                                            

                                                                       
                                                                           
                                                 






















                                                                                           
                                                         






                                                                 
    


                                                                      

                                                                          



                               





                                                                         

                                                        


                                                
#!/bin/sh
# Copyright (c) 2007 - RZ Uni Freiburg
# Copyright (c) 2007 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found under http://openslx.org
#
# Universal (distro independent) xorg.conf preparation script for OpenSLX 
# linux stateless clients, depending on ddcprobe
#
# this tool produces a 1024x768 standard resolution if no monitor was
# detected (problems on some older i8XX, newer NVidia, and ATI adaptors)

#############################################################################
# local functions used within - check if the monitor might be an older crt
iscrt () {
local dim=$1
local year=$2
# first three characters (CRT/TFT) are interpreted later
local crt="CRT Generic"
# sub 17" displays
if [ $dim -lt 750 ] ; then
  # modern crt should have a size of 17"+
  if [ $year -gt 1998 ] ; then crt="TFT 4:3 <17inch" ; fi
# 17" crt displays, little bit smaller than tfts
elif [ $dim -lt 900 ] ; then
  crt="CRT 17inch"
  echo -e "1280x1024\n1152x864" > /tmp/res
# 19" crt / sub 19" tft
elif [ $dim -lt 1000 ] ; then
  if [ $year -lt 2001 ] ; then
    crt="CRT 19inch"
    echo -e "1400x1050\n1280x1024\n1152x864" > /tmp/res
  else
    crt="TFT 4:3 17''"
  fi
# 18/19" tft displays (available after 2001)
elif [ $dim -lt 1200 ] ; then  
  if [ $year -ge 2002 ] ; then
    crt="TFT 4:3 18(+)''"
  else
    crt="CRT 20''"
    echo -e "1400x1050\n1280x1024\n1152x864" > /tmp/res
  fi
# sub 22" displays are crts if older than 2004 :)
elif [ $dim -lt 1300 ] ; then
  if [ $year -ge 2004 ] ; then
    crt="TFT 4:3 19(+)''"
  else
    crt="CRT 20(+)''"
    echo -e "1600x1200\n1400x1050\n1280x1024\n1152x864" > /tmp/res
  fi
# any bigger display is most probably a tft (and nobody should have bought
# a big crt after 2003 :))
elif [ $year -ge 2004 ] ; then
  crt="TFT 4:3 22+''"
fi
echo "$crt"
}

#############################################################################
# main script

# functions common for all distros
. /etc/functions
# functions common for all distros, messages contains all error and
# info output
. /etc/messages
# load distro specific configuration variables and functions. distro
# specific functions may overwrite functions defined in /etc/functions
. /etc/sysconfig/config
. /etc/distro-functions

xfc="/tmp/xorg.conf"
echo -e "# ${D_XF86CONFFILE}\n# autogenerated X hardware configuration by \
xconfig in OpenSLX stage3\n# DO NOT EDIT THIS FILE BUT 'xconfig' INSTEAD" \
  > $xfc
echo '
Section "Files"
EndSection
Section "ServerFlags"
  Option       "AllowMouseOpenFail"
  Option       "blank time"        "5"
  Option       "standby time"      "10"
  Option       "suspend time"      "15"
  Option       "off time"          "20"
EndSection
Section "Module"
  Load         "i2c"
  Load         "bitmap"
  Load         "ddc"
  Load         "extmod"
  Load         "freetype"
  Load         "int10"
  Load         "vbe"
  Load         "glx"
  Load         "dri"
EndSection
Section "InputDevice"
  Identifier "Generic Keyboard"
  Driver       "kbd"
  Option       "CoreKeyboard"
  Option       "XkbRules"          "xorg"
  Option       "XkbModel"          "pc105"
  Option       "XkbLayout"         "XKEYBOARD"
  Option       "XkbVariant"        "nodeadkeys"
EndSection
Section "InputDevice"
  Identifier   "Generic Mouse"
  Driver       "mouse"
  Option       "CorePointer"
  Option       "Device"            "/dev/input/mice"
  Option       "Protocol"          "ImPS/2"
  Option       "ZAxisMapping"      "4 5"
  Option       "Emulate3Buttons"   "true"
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "stylus"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "stylus"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "eraser"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "eraser"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "cursor"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "cursor"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "Device"
  Identifier   "Generic Video Card"
  Driver       "vesa"
EndSection
Section "Monitor"
  Identifier   "Generic Display"
  Option       "DPMS"
EndSection
Section "Screen"
  Identifier   "Default Screen"
  Device       "Generic Video Card"
  Monitor      "Generic Display"
  DefaultDepth 24
  SubSection "Display"
    Depth        24
    Modes        "1024x768" "800x600"
  EndSubSection
EndSection
Section "ServerLayout"
  Identifier   "Default Layout"
  Screen       "Default Screen"
  InputDevice  "Generic Keyboard"
  InputDevice  "Generic Mouse"
  InputDevice  "stylus"            "SendCoreEvents"
  InputDevice  "cursor"            "SendCoreEvents"
  InputDevice  "eraser"            "SendCoreEvents"
EndSection
Section "DRI"
  Mode    0666
EndSection
' >> $xfc
# read ddcprobe output (the adaptor VESA capabilities are of no interest)
ddcprobe|sed "/mode: /d"|while read line ; do 
  case $line in
    ctiming*|dtiming*)
      Res=$(echo $line|sed "s/.*:\ //;s/@.*//")
      Width=${Res%%x*}
      Height=${Res##*x}
      # we need exact resolutions for tft displays only and we want to filter
      # quadratic resolutions (bug of ddcprobe??)
      [ "${IsCrt%% *}" = "TFT" -a $((${Width}00 / ${Height})) -ge 125 ] && \
        echo $Res >> /tmp/res
      # add information on grafic adaptor and monitor (no practical use
      # nevertheless)
      [ "x${VendorName}" = "x" ] && VendorName="No vendor string detected" 
        grep ModelName $xfc 2>&1 > /dev/null || \
          sed -e "/Section \"Monitor\"/a\ \ ModelName    \"Display - ${IsCrt}\"" \
              -e "/Section \"Device\"/a\ \ VendorName   \"${VendorName}\"" \
              -i $xfc	  
    ;;
    monitorname*|monitorid*)
      [ "x${line##monitor*:}" = "x" ] || sed "s/Display - /${line##monitor*: } - /" -i $xfc
    ;;
    product*)
      [ "$line" != "product:" ] && \
        sed "/Section \"Device\"/a\ \ BoardName    \"${line##product: }\"" \
          -i $xfc
    ;;
    oem*|vendor*)
      [ "x${line##?e*:}" = "x" ] || VendorName="${line##?e*: }"
    ;;
    manufacture*)
      Year=${line##* }
    ;;
    screensize*)
      Dim=${line##screensize: }
      Width=${Dim%% *}
      Height=${Dim##* }
      Dim=$(($Width * $Height))
      # check for geometry - no crt if no 4:3 pixel ratio
      if [ $((${Width}00 / $((${Height} + 1 )))) -lt 140 ] ; then
        IsCrt="$(iscrt $Dim $Year)"
      else
        IsCrt="TFT WideScreen"
      fi
    ;;
  esac
done

# if predefined value is present otherwise use computed/detected stuff
if [ -n "${hw_monitor}" ] ; then
  # just cut all starting from k(Hz), do we need the option to set maximum
  # monitor capabilities?
  #HS=${hw_monitor%k*}
  #VS=${hw_monitor%Hz*}
  Modes="\"${hw_monitor##* }\""
else
  # to be checked if correct
  if [ -f /tmp/res ] ; then
    for line in $(sort -run /tmp/res) ; do Modes="$Modes \"$line\""; done
  else
    error "$hcfg_res" nonfatal
  fi
fi
sed "s/Modes        \"/Modes       ${Modes} \"/" -i $xfc
# displayvars
#displayvars
#sed "/Section \"Device\"/a\ \ ${Files}" -i $xfc