4fbda014f9e8a0bd52a2dbc0294af1dd144d2905
[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
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 if [ $CPUTYPE = "OMAP3530" ]; then
34         echo Starting PVR
35         insmod $(busybox find /lib/modules/$(uname -r) -name "pvrsrvkm.ko")
36         #modprobe bc_example
37         modprobe omaplfb
38         modprobe bufferclass_ti
39
40         pvr_maj=`grep "pvrsrvkm$" /proc/devices | cut -b1,2,3`
41         bc_maj=`grep "bc" /proc/devices | cut -b1,2,3`
42
43         if [ -e /dev/pvrsrvkm ] ; then 
44                 rm -f /dev/pvrsrvkm
45         fi
46
47         mknod /dev/pvrsrvkm c $pvr_maj 0 
48         chmod 666 /dev/pvrsrvkm
49
50         if [ -e /dev/bc_cat ] ; then
51                 rm -f /dev/bc_cat
52         fi
53
54         mknod /dev/bc_cat c $bc_maj 0
55         chmod 666 /dev/bc_cat
56
57         touch /etc/powervr-esrev
58
59         SAVED_ESREVISION="$(cat /etc/powervr-esrev)"
60
61         devmem2 0x48004B48 w 0x2 > /dev/null
62         devmem2 0x48004B10 w 0x1 > /dev/null
63         devmem2 0x48004B00 w 0x2 > /dev/null
64
65         ES_REVISION="$(devmem2 0x50000014 | sed -e s:0x10205:5: -e s:0x10201:3: -e s:0x10003:2: | tail -n1 | awk -F': ' '{print $2}')"
66
67         if [ "${ES_REVISION}" != "${SAVED_ESREVISION}" ] ; then
68                 echo -n "Starting SGX fixup for"
69                 echo " ES${ES_REVISION}.x"
70                 cp -a /usr/lib/ES${ES_REVISION}.0/* /usr/lib
71                 cp -a /usr/bin/ES${ES_REVISION}.0/* /usr/bin    
72                 echo "${ES_REVISION}" > /etc/powervr-esrev
73         fi
74         /usr/bin/pvrsrvinit
75 else
76         echo No SGX hardware, not starting PVR
77 fi
78