#!/bin/sh
PATH=/bin/:/sbin/:/usr/bin/:/usr/sbin:/usr/local/sbin:/usr/local/bin
export PATH
echo clock rate $1
if [ -z "$1" ]; then
	exit 1
fi

DEVCAP_POOL_DIR=/etc/default/devcap_pool
SERIAL=`echo $1 | cut -c 1-5 | cut -d- -f1`
[ -f ${DEVCAP_POOL_DIR}/${SERIAL}.conf ] && . ${DEVCAP_POOL_DIR}/${SERIAL}.conf

if [ -z "$SENSOR_ID" ]; then
	echo "devcap: ${DEVCAP_POOL_DIR}/${SERIAL}.conf not found."
	exit 1
fi

fw_setenv pll0 70

if [ "$ISP_TYPE" != "A1_ISP" ]; then
	fw_setenv pll1 62
	fw_setenv isp 94
	exit 0
fi

case $SENSOR_ID in
    "OV9715")
        fw_setenv pll1 33
        fw_setenv isp 68
    ;;
    "AR0331")
        if [ "$RESOLUTION_1" = "N1280x720" ]; then
            echo "Special case: AR0331 -> 1M model"
            fw_setenv pll1 33
            fw_setenv isp 102
        else
            fw_setenv pll1 62
            fw_setenv isp 94
        fi
    ;;
    "OV5653" | "IMX122" | "AR0130" | "MT9J003")
        fw_setenv pll1 62
        fw_setenv isp 94
	;;
    *) # IMX136, IMX222
        fw_setenv pll1 62
        fw_setenv isp 94
    ;;

esac
 
exit 0
