Improve init script file to: 28/2228/1 accepted/1.0/20121026.174056 submit/1.0/20121026.180058 submit/1.0_post/20121023.015205 submit/trunk/20121026.175654
authorGeoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Fri, 19 Oct 2012 09:36:12 +0000 (11:36 +0200)
committerGeoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Fri, 19 Oct 2012 09:36:12 +0000 (11:36 +0200)
 - Detect if EMGD should even be loaded
 - Detect if the user has manually set the configid option

Update spec file to:
 - use macro instead of hardcoded paths
 - Requires module-init-tools instead of kmod

Change-Id: Icc14cf4fa2efd2c4bb23e761fe7e4c8ef903882c

packaging/intel-emgd-kmod.spec
service/intel-emgd-kmod.init

index 35fceb8..82dced4 100644 (file)
@@ -32,12 +32,11 @@ Version: 3104
 Release: 1%{?dist}
 License: GPL v2
 Vendor: Intel
-Group: System/Kernel
+Group: System Environment/Kernel
 Source0: %{name}-%{version}.tar.gz
 BuildRequires: kernel-adaptation-intel-automotive-devel
-BuildRequires: kmod
 Requires: pciutils
-Requires: kmod
+Requires: module-init-tools
 Requires(post): /bin/ln
 %if %{kernel_number_str} != ""
 Requires: kernel-adaptation-intel-automotive = %{kernel_number}
@@ -55,12 +54,12 @@ Intel EMGD kernel module for kernel
 make -C drivers %{?_smp_mflags}
 
 %install
-mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system/basic.target.wants/
-mkdir -p $RPM_BUILD_ROOT/usr/libexec/
+mkdir -p $RPM_BUILD_ROOT%{_libdir}/systemd/system/basic.target.wants/
+mkdir -p $RPM_BUILD_ROOT%{_libexecdir}
 install -m 755 -d $RPM_BUILD_ROOT%{modpath}
 install -m 744 drivers/emgd.ko $RPM_BUILD_ROOT%{modpath}
-install -m 755 -D service/%{name}.service $RPM_BUILD_ROOT/usr/lib/systemd/system/
-install -m 755 -D service/%{name}.init $RPM_BUILD_ROOT/usr/libexec/
+install -m 755 -D service/%{name}.service $RPM_BUILD_ROOT%{_libdir}/systemd/system/
+install -m 755 -D service/%{name}.init $RPM_BUILD_ROOT%{_libexecdir}
 
 ln -sf ../%{name}.service $RPM_BUILD_ROOT/%{_libdir}/systemd/system/basic.target.wants/%{name}.service
 
@@ -92,4 +91,4 @@ fi
 %{modpath}/emgd.ko
 %{_libdir}/systemd/system/%{name}.service
 %{_libdir}/systemd/system/basic.target.wants/%{name}.service
-/usr/libexec/%{name}.init
+%{_libexecdir}/%{name}.init
index 37beb5f..fa93b74 100644 (file)
@@ -1,19 +1,20 @@
-#!/bin/sh
+#!/bin/bash
 
-##################################################################
+######################################################################
 #
-#        Russellville  CrownBay    CrossvilleOKI    ML7213   NexCOM
-#monitor LVDS 7       LVDS 13     LVDS 7           LVDS 13   LVDS 7
-#Gfx     8086:8108    8086:4108   8086:4108        8086:4108 8086:4108
+#        Russellville  CrownBay    CrossvilleOKI   ML7213    NexCom
+#monitor LVDS 7        LVDS 13     LVDS 7          LVDS 13   LVDS 7
+#Gfx     8086:8108     8086:4108   8086:4108       8086:4108 8086:4108
 #
-#################################################################
+######################################################################
 #
 #       unknown
 # 1     Russellville                    DEVICE has 8086:8108
 # 2     CrownBay                        VENDOR !has 10db && DEVICE has 8086:4108
-# 3     CrossivilleOKI                 VENDOR has 10db && DEVICE has 8086:4108
+# 3     CrossvilleOKI                  VENDOR has 10db && DEVICE has 8086:4108
 
-DEVICE_LSPCI=`lspci -n | cut -d$' ' -f3`
+PATH=$PATH:/bin:/sbin:/usr/bin
+DEVICE_LSPCI=`lspci -n | cut -d$' ' -f3 -s`
 
 find_board_type() {
        local __resultvar=$1
@@ -54,7 +55,7 @@ find_board_type() {
                elif [ $IS_CROWNBAY == '1' ]; then
                        _board_type='CrownBay'
                else
-                       _board_type='NextCom'
+                       _board_type='NexCom'
                fi
        else
                _board_type='unknown'
@@ -67,20 +68,55 @@ find_board_type() {
 
 platform="unknown"
 set_config() {
-        boardname=`find_board_type $platform`
-       configid=3
-       if [ $boardname == 'CrownBay' ]
-       then
-               configid=2
-       elif [ $boardname == 'Russellville' ] || [ $boardname == 'CrossvilleOKI' ]
-       then
-               configid=1
-       fi
+       IS_EMGD_NEEDED=0
+       for entry in $DEVICE_LSPCI; do
+               VENDOR_ID=0x`echo $entry | cut -d':' -f1`
+               DEVICE_ID=0x`echo $entry | cut -d':' -f2`
+               if [[ $VENDOR_ID -eq 0x8086 ]]; then
+                       case $DEVICE_ID in
+                               0x410[8-f] | 0x8108 | 0x8182 )
+                                       # This should cover all Intel Poulsbo and E6xx (Tunnel Creek) graphics core
+                                       echo "Found a Graphics core supported by EMGD: $entry"
+                                       IS_EMGD_NEEDED=1
+                                       ;;
+                       esac
+               fi
+       done
+
+       if [[ $IS_EMGD_NEEDED -ne 0 ]]; then
+               IS_CONFIGID_SET=`modprobe -c | grep 'options emgd' | grep configid -c`
+               if [[ $IS_CONFIGID_SET -eq 0 ]]; then
+                       # Trying to get a good value by default based on board type
+                       boardname=`find_board_type $platform`
+                       configid=0
+                       if [ $boardname == 'NexCom' ];
+                       then
+                               configid=3
+                       elif [ $boardname == 'CrownBay' ];
+                       then
+                               configid=2
+                       elif [ $boardname == 'Russellville' ] || [ $boardname == 'CrossvilleOKI' ];
+                       then
+                               configid=1
+                       fi
+
+                       if [ $boardname != 'unknown' ];
+                       then
+                               echo "Boardname is $boardname, configid=$configid"
+                               modprobe emgd configid=$configid
+                       else
+                               echo "Could not determine what board we are running on, please set configid manually"
+                       fi
+               else
+                       # There is a specific configuration given in /etc/modprobe.d/, use that one
+                       echo "configid parameter set by user (via /etc/modprobe.d/)"
+                       modprobe emgd
+               fi
 
-       # If an appropriate weston configuration file has not been created then create it
-       if [ ! -f /root/.config/weston.ini ]; then
-           /bin/mkdir -p /root/.config
-           /bin/cat > /root/.config/weston.ini <<EOF
+               # If an appropriate weston configuration file has not been created then create it
+               if [ ! -f /root/.config/weston.ini ]; then
+                       mkdir -p /root/.config
+                       cat > /root/.config/weston.ini <<EOF
 [shell]
 type=desktop-shell.so
 locking=false
@@ -94,10 +130,9 @@ name=LVDS1
 mode= 60.00 800 864 976 1088 480 486 494 517 -hsync +vsync ==
 
 EOF
-fi
-
-        echo "Boardname is $boardname, configid=$configid"
-        /sbin/modprobe emgd configid=$configid
+               fi
+       fi
 }
+
 set_config
 exit $?