diff options
Diffstat (limited to 'xpp/initialize_registers')
-rwxr-xr-x | xpp/initialize_registers | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/xpp/initialize_registers b/xpp/initialize_registers index 35386ce..6c07e94 100755 --- a/xpp/initialize_registers +++ b/xpp/initialize_registers @@ -1,23 +1,59 @@ #! /bin/sh -# XPD_BUS - bus name -# XPD_NAME - xpd name -# XPD_TYPE - xpd type number (from protocol reply): +# +# $Id$ +# +# This script is run from the xpp kernel module upon detection +# of a new XPD. +# +# Expects the following environment variables to be set: +# XPD_BUS - bus name +# XPD_NAME - xpd name +# XPD_TYPE - xpd type number (from protocol reply): # 3 - FXS # 4 - FXO -# XPD_REVISION - xpd revision number +# XPD_REVISION - xpd revision number set -e LOGGER="logger -i -t `basename $0`" - +opermode='FCC' INIT_DIR=`dirname $0` -BASE=/proc/xpp +XPP_BASE=/proc/xpp + +if [ -r /etc/default/zaptel ] +then . /etc/default/zaptel +fi + +export XPP_BASE -SLICS="$BASE/$XPD_BUS/$XPD_NAME/slics" +SLICS="$XPP_BASE/$XPD_BUS/$XPD_NAME/slics" FILE="$INIT_DIR/init_data_${XPD_TYPE}_${XPD_REVISION}.cmd" +set_daa_country_params() { + # based on fxo_modes from wctdm.c . TODO: more decent calculation? + reg16=00; reg26=00; reg30=00; reg31=A3; ring_osc=; ring_x=; + mode="$1" + # TODO: a saner fall-back in case of an unknown mode + if [ "$mode" = '' ]; then mode='FCC'; fi + if [ -r $INIT_DIR/init_fxo_modes ]; then + . $INIT_DIR/init_fxo_modes + fi + cat <<EOF >$SLICS +FF FF 00 00 WD 10 $reg16 +FF FF 00 00 WD 1A $reg26 +FF FF 00 00 WD 1E $reg30 +FF FF 00 00 WD 1F $reg31 +EOF + # for the FXS: + #if [ "$ring_osc" != '' ]; then + # /bin/echo "31 WI __ $ring_osc" >$SLICS + #fi + #if [ "$ring_x" != '' ]; then + # /bin/echo "31 WI __ $ring_x" >$SLICS + #fi +} if [ ! -f "$SLICS" ]; then - $LOGGER "missing slics file '$SLICS'" + $LOGGER "missing register file '$SLICS'" exit 1 fi @@ -28,7 +64,9 @@ fi case "$XPD_TYPE" in 3|4) + if [ "$XPD_TYPE" = 3 ]; then "$INIT_DIR/calibrate_slics"; fi cat "$FILE" > "$SLICS" + if [ "$XPD_TYPE" = 4 ]; then set_daa_country_params "$opermode"; fi ;; *) $LOGGER "Unknown type '$XPD_TYPE'" |