#!/bin/sh
#
# initial audio set.
#

case $1 in
    set)
        volume_out=$2
        volume_in=$3
    ;;
    resume)
        volctrl_path="/oem/etc/volctrl.conf"
        volume_out=`sysconf ${volctrl_path} get volume volume_out`
        volume_in=`sysconf ${volctrl_path} get volume volume_in`
    ;;
    *)
        volctrl_path="/oem/etc/volctrl.conf"
        volume_out=`sysconf ${volctrl_path} get volume volume_out`
        volume_in=`sysconf ${volctrl_path} get volume volume_in`
    ;;
esac

# Set output volume
case ${volume_out} in
    10)
        value_out=100
    ;;
    9)
        value_out=96
    ;;
    8)
        value_out=93
    ;;
    7)
        value_out=90
    ;;
    6)
        value_out=85
    ;;
    5)
        value_out=80
    ;;
    4)
        value_out=74
    ;;
    3)
        value_out=66
    ;;
    2)
        value_out=51
    ;;
    1)
        value_out=35
    ;;
    0)
        value_out=0
    ;;
esac

/usr/bin/amixer -q sset 'Master',0 ${value_out}

# Set input volume
case ${volume_out} in
    10)
        value_in=192
        ;;
    9)
        value_in=187
        ;;
    8)
        value_in=180
        ;;
    7)
        value_in=173
        ;;
    6)
        value_in=165
        ;;
    5)
        value_in=156
        ;;
    4)
        value_in=144
        ;;
    3)
        value_in=129
        ;;
    2)
        value_in=108
        ;;
    1)
        value_in=72
        ;;
    0)
        value_in=0
        ;;
esac

/usr/bin/amixer -q sset 'ADC',0 ${value_in}

exit 0