#! /bin/sh # # $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 set -e LOGGER="logger -i -t `basename $0`" opermode='FCC' INIT_DIR=`dirname $0` XPP_BASE=/proc/xpp if [ -r /etc/default/zaptel ] then . /etc/default/zaptel fi export XPP_BASE 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 <$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 register file '$SLICS'" exit 1 fi if [ ! -f "$FILE" ]; then $LOGGER "missing register initialization file '$FILE'" exit 1 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'" exit 2 esac $LOGGER "Wrote '$FILE' into '$SLICS'" exit 0