#!/bin/bash
KERNELREL=`uname -r`
DTSFILE=`cat /proc/device-tree/vendorinfo/display_dtb`
TOUCHCONTR=`cat /sys/devices/ocp.2/4819c000.i2c/i2c-2/2-0038/input/input1/name`

if [ $KERNELREL == "3.12.30" ]; then
    echo -e "$DTSFILE\n$TOUCHCONTR\n"
    if [[ $TOUCHCONTR == "EP0430M"* ]]; then
        echo "4.3\" Display, check if Right DTS"
        
        if [ $TOUCHCONTR == "EP0430MG1" ] && [ $DTSFILE != "Display001_4_2020.dtb" -a $DTSFILE != "Display001_4_nopruss_2020.dtb" ]; then
        	if [[ $DTSFILE == *"_nopruss"* ]]; then
         	    echo "switch to new2020 nopruss";
         	    /root/DisplayTo_4_3inch_nopruss_2020.sh
         	    reboot
        	else
        	    echo "switch to new2020";
        	    /root/DisplayTo_4_3inch_2020.sh
        	    reboot
        	fi
        fi
        if [ $TOUCHCONTR == "EP0430M09" ] && [ $DTSFILE != "Display001_4.dtb" -a $DTSFILE != "Display001_4_nopruss.dtb" ] ; then
        	if [[ $DTSFILE == *"_nopruss"* ]]; then
         	    echo "switch to old nopruss";
         	    /root/DisplayTo_4_3inch_nopruss.sh
         	    reboot
        	else
        	    echo "switch to old";
        	    /root/DisplayTo_4_3inch.sh
        	    reboot
        	fi
        	
        fi
        
    fi
else
    echo "Kernelrelease ($KERNELREL) not applicable"
fi
