1c99096b01fc4a015c88f9b744d93a7cc1897eda
[profile/ivi/intel-emgd-kmod.git] / service / intel-emgd-kmod.init
1 #!/bin/sh
2
3 ##################################################################
4 #
5 #        Russellville  CrownBay    CrossvilleOKI    ML7213   NexCOM
6 #monitor LVDS 7       LVDS 13     LVDS 7           LVDS 13   LVDS 7
7 #Gfx     8086:8108    8086:4108   8086:4108        8086:4108 8086:4108
8 #
9 #################################################################
10 #
11 #       unknown
12 # 1     Russellville                    DEVICE has 8086:8108
13 # 2     CrownBay                        VENDOR !has 10db && DEVICE has 8086:4108
14 # 3     CrossivilleOKI                  VENDOR has 10db && DEVICE has 8086:4108
15
16 DEVICE_LSPCI=`lspci -n | cut -d$' ' -f3`
17
18 find_board_type() {
19         local __resultvar=$1
20         local _board_type="unknown"
21         local IS_8108='0'
22         local IS_4108='0'
23         local IS_ML7213='0'
24         local IS_CROWNBAY='0'
25         local oldIFS=$IFS
26         #set -x
27         for entry in $DEVICE_LSPCI; do
28                 #echo $entry
29                 IFS=$':'
30                 set -- $entry
31
32                 VENDOR=`echo $1`
33                 DEVICE=`echo $2`
34                 if [ $VENDOR == '8086' ]; then
35                         if [ $DEVICE == '8108' ]; then 
36                                 IS_8108='1'
37                                 break
38                         elif [ $DEVICE == '4108' ]; then
39                                 IS_4108='1'
40                         fi
41                 elif [ $VENDOR == '10db' ]; then
42                         IS_ML7213='1'
43                 elif [ $VENDOR == '12d8' ]; then
44                         IS_CROWNBAY='1'
45                 fi
46                 IFS=$oldIFS
47         done
48
49         if [ $IS_8108 == '1' ]; then
50                 _board_type='Russellville'
51         elif [ $IS_4108 == '1' ]; then
52                 if [ $IS_ML7213 == '1' ]; then
53                         _board_type='CrossvilleOKI'
54                 elif [ $IS_CROWNBAY == '1' ]; then
55                         _board_type='CrownBay'
56                 else
57                         _board_type='NextCom'
58                 fi
59         else
60                 _board_type='unknown'
61         fi
62
63         # This logic is stupid and the reliable method is to query the firmware interface, which now is not available yet.
64
65         echo "$_board_type"
66 }
67
68 platform="unknown"
69 set_config() {
70         boardname=`find_board_type $platform`
71         configid=3
72         if [ $boardname == 'CrownBay' ]
73         then
74                 configid=2
75         elif [ $boardname == 'Russellville' ] || [ $boardname == 'CrossvilleOKI' ]
76         then
77                 configid=1
78         fi
79
80         # If an appropriate weston configuration file has not been created then create it
81         if [ ! -f /root/.config/weston.ini ]; then
82             /bin/mkdir -p /root/.config
83             cat > /root/.config/weston.ini <<EOF
84 [shell]
85 type=desktop-shell.so
86 locking=false
87
88 [launcher]
89 icon=/usr/share/weston/terminal.png
90 path=/usr/bin/weston-terminal
91
92 [output]
93 name=LVDS1
94 mode= 60.00 800 864 976 1088 480 486 494 517 -hsync +vsync ==
95
96 EOF
97 fi
98
99         echo "Boardname is $boardname, configid=$configid"
100         /sbin/modprobe emgd configid=$configid
101 }
102 set_config
103 exit $?