~ubuntu-branches/ubuntu/saucy/dahdi-tools/saucy

« back to all changes in this revision

Viewing changes to xpp/xpp_fxloader

  • Committer: Stefan Lesicnik
  • Date: 2011-05-08 12:22:46 UTC
  • mfrom: (2.1.4 sid)
  • Revision ID: stefan@lsd.co.za-20110508122246-lh6k2x1uy8pl3vdi
Tags: 1:2.4.1-1ubuntu1
* Merge from Debian. Remaining changes:
  - Bug Fix: If linux-headers are not installed, don't block, and print
    information for the user.
  - added debian/dahdi.postinst
  - added --error-handler=init_failed to debian/rules
  - Changes from Debian:
    - debian/control: Change Maintainer
    - debian/control: Removed Uploaders field.
    - debian/control: Removed Debian Vcs-Svn entry and replaced with
      ubuntu-voip Vcs-Bzr, to reflect divergence in packages.
    - debian/control: Package dahdi Depends on dahdi-dkms | dahdi-source
* debian/control: Added gawk as dependency for dkms build (LP: #493304)
* New upstream release (Closes: #581076, #582094).
* Patches hardware_rescan, perl_fix_noserial, perl_fix_transportdir,
  astribank_allow_ignoreend, init_unload_modules and wcb4xxp_extra_trunk
  dropped: merged upstream.
* dahdi-linux 2.3.0 is required (extra config options for dahdi_cfg).
* Convert to dpkg v.3 format.
* Standards version: 3.9.1.0 (No change needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
3
# xpp_fxloader: load Xorcom Astribank (XPP) firmware
4
 
# $Id: xpp_fxloader 7814 2010-01-10 11:02:04Z tzafrir $
 
4
# $Id: xpp_fxloader 9740 2011-02-08 14:04:50Z tzafrir $
5
5
#
6
6
# Written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
7
7
# Copyright (C) 2006-2009, Xorcom
45
45
export PATH
46
46
 
47
47
me=`basename $0`
 
48
dir=`dirname $0`
 
49
PATH="$dir:$PATH"
48
50
DEFAULTS="/etc/dahdi/init.conf"
49
51
 
50
52
if [ -t 2 ]; then
65
67
FIRMWARE_DIR="${FIRMWARE_DIR:-/usr/share/dahdi}"
66
68
ASTRIBANK_HEXLOAD=${ASTRIBANK_HEXLOAD:-/usr/sbin/astribank_hexload}
67
69
ASTRIBANK_TOOL=${ASTRIBANK_TOOL:-/usr/sbin/astribank_tool}
 
70
XPP_UDEV_SLEEP_TIME="${XPP_UDEV_SLEEP_TIME:-15}"
68
71
 
69
72
USB_FW="${USB_FW:-USB_FW.hex}"
70
73
 
211
214
}
212
215
 
213
216
reset_fpga() {
214
 
  totaldevs=`numdevs e4e4 '11[3456][012]'`
 
217
  totaldevs=`numdevs e4e4 '11[3456][0123]'`
215
218
  devices=`find_dev e4e4 '11[3456][12]'`
216
219
  debug "Reseting devices [$totaldevs devices]"
217
220
  for dev in $devices
221
224
        run_astribank_tool -D "$dev" -r full 2>&1 >/dev/null
222
225
  done
223
226
  if [ "$1" = 'wait' ]; then
224
 
          wait_renumeration $totaldevs e4e4 '11[3456]0'
 
227
          wait_renumeration $totaldevs e4e4 '11[3456][03]'
225
228
  fi
226
229
}
227
230
 
264
267
        reset_fpga
265
268
        ;;
266
269
xppdetect|load|usb)
267
 
        numdevs=`numdevs e4e4 '11[3456][01]'`
 
270
        numdevs=`numdevs e4e4 '11[3456][013]'`
268
271
        $LOGGER -- "--------- FIRMWARE LOADING: ($1) [$numdevs devices]"
269
272
 
270
273
        load_usb_fw e4e4 1130 $USB_FW
311
314
        exit 0
312
315
fi
313
316
 
314
 
if [ "$ACTION" = "add" ] && [ -w "$DEVICE" ]
315
 
then
 
317
if [ "$ACTION" != add ]; then
 
318
        exit 0;
 
319
fi
 
320
 
 
321
# This procedure is run in the background to do the actual work of loading the
 
322
# firmware. Running it in the background allows udev to continue doing other tasks
 
323
# and thus provide a faster startup.
 
324
#
 
325
# On some systems (e.g. CentOS 5) we get the relevant udev event before the device
 
326
# file is ready. Which is why we want the background process to wait a bit first.
 
327
udev_delayed_load() {
 
328
        sleep 0.2
 
329
        # Make sure the new device is writable:
 
330
        usb_dev_writable=0
 
331
        for i in `seq $XPP_UDEV_SLEEP_TIME`; do
 
332
                if [ -w "$DEVICE" ]; then
 
333
                        usb_dev_writable=1;
 
334
                        break;
 
335
                fi
 
336
                sleep 1
 
337
        done
 
338
        if [ $usb_dev_writable != 1 ]; then
 
339
                $LOGGER "Device $DEVICE not writable. Can't load firmware."
 
340
                return;
 
341
        fi
 
342
 
316
343
        $LOGGER "Trying to find what to do for product $PRODUCT, device $DEVICE"
317
344
        prod_id=`echo "$PRODUCT" | cut -d/ -f2`
318
345
        case "$PRODUCT" in
322
349
                run_fxload -D "$DEVICE" -I "$FIRM_USB"
323
350
                ;;
324
351
        e4e4/11[3456]1/*)
 
352
                # There are potentially two separate udev events, for
 
353
                # each of the two endpoints. Ignore the first interface:
 
354
                case "$DEVPATH" in *.0) exit 0;; esac
325
355
                if [ "$prod_id" = 1131 ]; then
326
356
                        FIRM_FPGA="FPGA_FXS.hex"        # Legacy
327
357
                else
331
361
                load_fw_device "$DEVICE" "$FIRM_FPGA"
332
362
                ;;
333
363
        esac    
334
 
fi
 
364
}
 
365
 
 
366
udev_delayed_load &
 
367