#!/bin/sh

hasVoice=$(db -q get hw.board.hasVoice)
[ "$hasVoice" = "1" ] || exit 0

SLIC=$(cat /proc/device-tree/airoha-voice/slic-type)
[ "${SLIC#pef}" != "${SLIC}" ] && {
    echo Configure TxGain and RxGain for MXL SLIC $SLIC

    ports=$(db -q get hw.board.VoicePorts)
    for p in $(seq 0 $((ports-1))); do
        uci set asterisk.extension${p}.txgain='10'
        uci set asterisk.extension${p}.rxgain='-15'
    done
}

hasDect=$(db -q get hw.board.hasDect)
[ "$hasDect" = "1" ] || exit 0

# Set the DECT RFPI
. /lib/functions/iopsys-environment.sh
db set hw.board.dect_rfpi=$(get_dect_rfpi)
db commit

# configure the PCM for DECT/DCX81
[ -f "/proc/device-tree/aliases/dcx81-uart" ] && {
    uci set dect.global.pcm_fsync='SHORT_LF'
    uci set dect.global.pcm_slot_start='8'
    uci set dect.global.dect_channel_start='3'
}
