Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/daemon/include/hwdetection.global.class

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1248 by niro, Wed Feb 2 20:20:24 2011 UTC revision 1335 by niro, Thu Feb 17 20:18:09 2011 UTC
# Line 1  Line 1 
1    #!/bin/bash
2  # $Id$  # $Id$
3    
4    provide hwdetection
5    
6  ## hwdetection, needs >= sys-apps/hwinfo  ## hwdetection, needs >= sys-apps/hwinfo
7    
8  # hwinfo wrapper to use hwinfo with sudo if requested  # hwinfo wrapper to use hwinfo with sudo if requested
# Line 68  get_hwinfo_smp() Line 71  get_hwinfo_smp()
71   echo "${smp}"   echo "${smp}"
72  }  }
73    
74    get_hwinfo_monitor()
75    {
76     local all
77     local hsync
78     local vsync
79     local resolution
80    
81     all="$(hwinfo --monitor)"
82     hsync=$(echo "${all}" | grep 'Hor.*Sync' | sed 's:.*\:\ \(.*\)\ kHz:\1:')
83     vsync=$(echo "${all}" | grep 'Vert.*Sync' | sed 's:.*\:\ \(.*\)\ Hz:\1:')
84     resolution=$(echo "${all}" | grep 'Max.*Resolution' | sed 's:.*\:\ \(.*\):\1:')
85    
86     #echo "hsync=\"${hsync}\""
87     #echo "vsync=\"${vsync}\""
88     #echo "resolution=\"${resolution}\""
89     echo "${hsync};${vsync};${resolution}"
90    }
91    
92  # get_driver_modules $hw_item  # get_driver_modules $hw_item
93  get_driver_modules()  get_driver_modules()
94  {  {
95   local item="$1"   local item="$1"
96   local modules   local modules
   
  # being little tricky here :)  
  # does following:  
  # grep:  
  # -> 'Driver Modules: "via82cxxx", "ide_cd"'  
  # cut:  
  # -> ' "via82cxxx", "ide_cd"'  
  # sed1:  
  # -> ' modules="via82cxxx", "ide_cd"'  
  # sed2:  
  # -> ' modules="via82cxxx ide_cd"'  
  # then evaluate -> eval modules="via82cxxx ide_cd"  
  # and we get a variable $modules with all mods  
  #eval $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 | sed -e "s:\":modules=\":" -e "s:\",\ \":\ :")  
   
97   local i   local i
98    
99   for i in $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 )   for i in $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 )
100   do   do
101   eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :")   eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :")
# Line 141  get_x11_driver_modules() Line 147  get_x11_driver_modules()
147   remove_duplicates "${modules}"   remove_duplicates "${modules}"
148  }  }
149    
150    get_evdev_device_path()
151    {
152     local device="$1"
153     local path
154    
155     case ${device} in
156     mouse|keyboard) true;;
157     *) die "unkown device";;
158     esac
159    
160     path="$(hwinfo --${device} | grep 'Device Files:' | sed 's:.*\(/dev/input/event[0-5]\).*:\1:')"
161     echo "${path}"
162    }
163    
164  # get_netcard_driver_modules device  # get_netcard_driver_modules device
165  # e.g. get_netcard_driver_modules eth0  # e.g. get_netcard_driver_modules eth0
166  get_netcard_driver_modules()  get_netcard_driver_modules()
# Line 227  create_initrd() Line 247  create_initrd()
247   local modules   local modules
248   # enabled framebuffer modules as default   # enabled framebuffer modules as default
249   local framebuffer=1   local framebuffer=1
250     local uvesafb_config="/etc/modprobe.d/uvesafb.conf"
251    
252   # very basic getops   # very basic getops
253   for i in $*   for i in $*
254   do   do
255   case $1 in   case $1 in
  #--root|-r) shift; root="$1" ;;  
256   --initrd|-i) shift; initrd="$1" ;;   --initrd|-i) shift; initrd="$1" ;;
257   --config|-c) shift; config="$1" ;;   --config|-c) shift; config="$1" ;;
258   --kernelversion|-v) shift; kernel="$1" ;;   --kernelversion|-v) shift; kernel="$1" ;;
# Line 248  create_initrd() Line 268  create_initrd()
268   if [[ ! -z ${INSTALL_ROOT} ]]   if [[ ! -z ${INSTALL_ROOT} ]]
269   then   then
270   config="${INSTALL_ROOT}/${config}"   config="${INSTALL_ROOT}/${config}"
271     uvesafb_config="${INSTALL_ROOT}/${uvesafb_config}"
272   chroot="chrooted"   chroot="chrooted"
273   fi   fi
274    
# Line 262  create_initrd() Line 283  create_initrd()
283   modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')"   modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')"
284   fi   fi
285    
286     # check for usb-storage and add usb host drivers
287     if [[ ! -z $(echo ${modules} | grep usb[_-]storage) ]]
288     then
289     # add usb1, usb1.1, usb2 and ubs3 hosts
290     modules+=" uhci-hcd ohci-hcd ehci-hcd xhci-hcd"
291     fi
292    
293   # add some generic modules   # add some generic modules
294   modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk"   modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk"
295    
296   # add generic framebuffer modules   # add generic framebuffer modules
297   [[ ${framebuffer} = 1 ]] && modules+=" uvesafb"   if [[ ${framebuffer} = 1 ]]
298     then
299     modules+=" uvesafb"
300    
301     # setup modprobe conf too
302     [[ ! -d $(dirname ${uvesafb_config}) ]] && install -d $(dirname ${uvesafb_config})
303     cat > ${uvesafb_config} << EOF
304    # This file sets the parameters for uvesafb module.
305    # The following format should be used:
306    # options uvesafb mode_option=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ...
307    #
308    # For more details see:
309    # http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt
310    #
311    EOF
312     # fix a issues with virtualbox and 'ywrap'
313     if [[ ! -z $(hwinfo --bios | grep -i virtualbox) ]]
314     then
315     # use redraw on virtualbox
316     echo "options uvesafb mode_option=1024x768-32@60 scroll=redraw" >> ${uvesafb_config}
317     else
318     # default config 1024x768 and 60 HZ
319     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" >> ${uvesafb_config}
320     fi
321     fi
322    
323   # remove all duplicate modules   # remove all duplicate modules
324   modules="$(remove_duplicates ${modules})"   modules="$(remove_duplicates ${modules})"

Legend:
Removed from v.1248  
changed lines
  Added in v.1335