#!/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=192
        ;;
    9)
        value_out=187
        ;;
    8)
        value_out=180
        ;;
    7)
        value_out=173
        ;;
    6)
        value_out=165
        ;;
    5)
        value_out=156
        ;;
    4)
        value_out=144
        ;;
    3)
        value_out=129
        ;;
    2)
        value_out=108
        ;;
    1)
        value_out=72
        ;;
    0)
        value_out=0
        ;;
esac

/usr/bin/amixer -q sset 'DAC',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