libgles-omap3: split support for ES revisions into subpackages where possible
[glsdk/meta-ti-glsdk.git] / recipes-graphics / libgles / libgles-omap3 / rc.pvr
1 #!/bin/sh
2 PATH=$PATH:/usr/sbin
4 BITSPERPIXEL="$(fbset | grep geom | awk '{print $6}')"
5 YRES="$(fbset | grep geom | awk '{print $3}')"
7 CPUTYPE="$(cputype)"
9 if [ "$1" = "" ]; then
10         echo PVR-INIT: Please use start, stop, or restart.
11         exit 1
12 fi
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
21 if [ "$1" = "stop" ]; then
22         exit 0
23 fi
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
30 # Try to enable triple buffering when there's enough VRAM
31 fbset -vyres $(expr $YRES \* 3) 
33 sgxprepare () {
34         echo Starting PVR
35         insmod $(busybox find /lib/modules/$(uname -r) -name "pvrsrvkm.ko")
36         modprobe omaplfb
37         modprobe bufferclass_ti
39         pvr_maj=`grep "pvrsrvkm$" /proc/devices | cut -b1,2,3`
40         bc_maj=`grep "bc" /proc/devices | cut -b1,2,3`
42         if [ -e /dev/pvrsrvkm ] ; then 
43                 rm -f /dev/pvrsrvkm
44         fi
46         mknod /dev/pvrsrvkm c $pvr_maj 0 
47         chmod 666 /dev/pvrsrvkm
49         touch /etc/powervr-esrev
51         SAVED_ESREVISION="$(cat /etc/powervr-esrev)"
52 }
54 sgxfinish () {
55         if [ "${ES_REVISION}" != "${SAVED_ESREVISION}" ] ; then
56                 echo -n "Starting SGX fixup for"
57                 echo " ES${ES_REVISION}.x"
58                 cp -a /usr/lib/ES${ES_REVISION}.0/* /usr/lib
59                 cp -a /usr/bin/ES${ES_REVISION}.0/* /usr/bin    
60                 echo "${ES_REVISION}" > /etc/powervr-esrev
61         fi
62         /usr/bin/pvrsrvinit
63 }
65 case $CPUTYPE in
66 "OMAP3530")
67         sgxprepare
69         devmem2 0x48004B48 w 0x2 > /dev/null
70         devmem2 0x48004B10 w 0x1 > /dev/null
71         devmem2 0x48004B00 w 0x2 > /dev/null
73         ES_REVISION="$(devmem2 0x50000014 | sed -e s:0x00010205:5: -e s:0x00010201:3: -e s:0x00010003:2: | tail -n1 | awk -F': ' '{print $2}')"
75         sgxfinish
76         ;;
77 "TI816x")
78         sgxprepare
80         devmem2 0x48180F04 w 0x0 > /dev/null
81         devmem2 0x48180900 w 0x2 > /dev/null
82         devmem2 0x48180920 w 0x2 > /dev/null
84         ES_REVISION="$(devmem2 0x56000014 | sed -e s:0x00010205:6: -e s:0x00010201:3: -e s:0x00010003:2: | tail -n1 | awk -F': ' '{print $2}')"
86         sgxfinish
87         ;;
88 *)
89         echo No SGX hardware, not starting PVR
90         ;;
91 esac