be77bc7deb71a4b669501c03801776978569cf02
[openembedded.git] / recipes / powervr-drivers / libgles-omap3 / rc.pvr
1 #!/bin/sh
2 PATH=$PATH:/usr/sbin
3
4 BITSPERPIXEL="$(fbset | grep geom | awk '{print $6}')"
5 YRES="$(fbset | grep geom | awk '{print $3}')"
6
7 CPUTYPE="$(cputype)"
8
9 if [ "$1" = "" ]; then
10         echo PVR-INIT: Please use start, stop, or restart.
11         exit 1
12 fi
13
14 if [ "$1" = "stop" -o  "$1" = "restart" ]; then
15         echo Stopping PVR
16         rmmod bufferclass_ti 2>/dev/null
17         rmmod omaplfb 2>/dev/null
18         rmmod pvrsrvkm 2>/dev/null
19 fi
20
21 if [ "$1" = "stop" ]; then
22         exit 0
23 fi
24
25 # Set RGBA ordering to something the drivers like
26 if [ "$BITSPERPIXEL" = "32" ] ; then
27         fbset -rgba 8/16,8/8,8/0,8/24
28 fi
29
30 # Try to enable triple buffering when there's enough VRAM
31 fbset -vyres $(expr $YRES \* 3) 
32
33         echo Starting PVR
34         insmod /lib/modules/$(uname -r)/kernel/drivers/gpu/pvr/pvrsrvkm.ko
35         insmod /lib/modules/$(uname -r)/kernel/drivers/gpu/pvr/omaplfb.ko
36         bc_ko="/lib/modules/$(uname -r)/kernel/drivers/gpu/pvr/bufferclass_ti.ko"
37         if test -f "$bc_ko"; then
38                 insmod $bc_ko
39         fi
40
41         if ! lsmod | grep -q pvrsrvkm; then
42                 echo pvrsrvkm failed to load
43                 exit 1
44         fi
45
46         #pvr_maj=`grep "pvrsrvkm$" /proc/devices | cut -b1,2,3`
47         #bc_maj=`grep "bc" /proc/devices | cut -b1,2,3`
48
49         #if [ -e /dev/pvrsrvkm ] ; then 
50         #       rm -f /dev/pvrsrvkm
51         #fi
52
53         #mknod /dev/pvrsrvkm c $pvr_maj 0 
54         chmod 666 /dev/pvrsrvkm
55
56         touch /etc/powervr-esrev
57
58         SAVED_ESREVISION="$(cat /etc/powervr-esrev)"
59
60         devmem2 0x48004B48 w 0x2 > /dev/null
61         devmem2 0x48004B10 w 0x1 > /dev/null
62         devmem2 0x48004B00 w 0x2 > /dev/null
63
64         ES_REVISION="$(devmem2 0x50000014 | sed -e s:0x10205:5: -e s:0x10201:3: -e s:0x10003:2: | tail -n1 | awk -F': ' '{print $2}')"
65
66         # enable hardware supervised domain power state transition - makes suspend work
67         devmem2 0x48004B48 w 0x3 > /dev/null
68
69         if [ "${ES_REVISION}" != "${SAVED_ESREVISION}" ] ; then
70                 echo -n "Starting SGX fixup for"
71                 echo " ES${ES_REVISION}.x"
72                 cp -a /usr/lib/ES${ES_REVISION}.0/* /usr/lib
73                 cp -a /usr/bin/ES${ES_REVISION}.0/* /usr/bin    
74                 echo "${ES_REVISION}" > /etc/powervr-esrev
75         fi
76         /usr/bin/pvrsrvinit