blob: 91ad874d1d468b4f9b541a9b62d11bc32720cd1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#!/bin/bash
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dialup/capi4k-utils/files/capi.hotplug,v 1.5 2005/04/24 13:31:48 genstef Exp $
. /etc/conf.d/capi
[ "$CAPI_HOTPLUG_USB" = "yes" ] || exit 0
# syslog output
syslog() { # <msg>
/usr/bin/logger -t "capi-usb" "$1"
}
beep_ok() {
[ "$CAPI_HOTPLUG_BEEP" = "yes" ] && echo -en "\033[10;1200]\a\033[10;262]" > /dev/console
}
beep_error() {
[ "$CAPI_HOTPLUG_BEEP" = "yes" ] && echo -en "\033[10;300]\a\033[10;262]" > /dev/console
}
# driver lookup
cardinfo() { # <driver>
# /proc/capi/controller: <controller> <drivername> <state> <cardname> <controllerinfo>
/bin/sed 2>/dev/null -n "s:^\([1-9][0-9]*\) \+${1} \+\([^ ]\+\) \+\([^ ]\+\) \+\([^ ]\+\):\1 \3 \2 \4:p" /proc/capi/controller
}
# AVM firmware loader
avmusb() { # <driver> <usbdev> <firmware>
local CARD NAME STATUS TYPE VER DEV FIRMWARE
while read CARD NAME STATUS TYPE VER DEV; do # AVM cardinfo
if [ "${STATUS}" = "detected" -a ${DEV} -eq ${2} ]; then
syslog "loading firmware '${3}' into controller ${CARD} (${NAME})"
/usr/sbin/avmcapictrl load "/lib/firmware/${3}" "${CARD}"
break
fi
done < <(cardinfo "${1}")
}
# normalize and split product code
# only needed, because coldplug gives other results than hotplug :-/
IFS="/" read _A _B _C < <(echo "${PRODUCT}")
read VENDOR DEVID PCLASS < <(/usr/bin/printf "%04x %04x %04x" "0x${_A}" "0x${_B}" "0x${_C}")
VENDID="${VENDOR}/${DEVID}"
DEVTMP="${DEVICE##/proc/bus/usb/}"
USBBUS="${DEVTMP%%/*}"
USBDEV="${DEVTMP##*/}"
LOCK="/tmp/.capi-usb-${USBBUS}-${USBDEV}"
LOADER=""
DRIVER=""
FIRMWARE=""
# select driver and firmware
case "${VENDID}" in
"057c/0c00") # FRITZCARD!USB
DRIVER="fcusb"
;;
"057c/1000") # FRITZCARD!USB v2.0
LOADER="avmusb"
DRIVER="fcusb2"
FIRMWARE="fus2base.frm"
;;
"057c/1900") # FRITZCARD!USB v2.1
LOADER="avmusb"
DRIVER="fcusb2"
FIRMWARE="fus3base.frm"
;;
"057c/2000") # FRITZX!USB
DRIVER="fxusb"
;;
"057c/2200") # BlueFRITZ!USB
LOADER="avmusb"
DRIVER="bfusb"
FIRMWARE="bfubase.frm"
;;
"057c/2300") # FRITZDSL!USB
LOADER="avmusb"
DRIVER="fcdslusb"
FIRMWARE="fdsubase.frm"
;;
"057c/2800") # FRITZX!USB OEM
DRIVER="fxusb_CZ"
;;
"057c/3500") # FRITZDSL!USB SL
LOADER="avmusb"
DRIVER="fcdslslusb"
FIRMWARE="fdlubase.frm"
;;
*) # unknown card
syslog "unknown USB product: ${VENDID}"
exit 1
esac
case "$ACTION" in
add)
/bin/ln 2>/dev/null -s "$$" "${LOCK}" || exit 0
# loading capi
if ! ( [ -f /proc/capi/capi20 ] || /sbin/modprobe -sq capi ); then
syslog "could not load CAPI!"
beep_error; /bin/rm -f "${LOCK}"; exit 1
fi
# loading driver
if ! /sbin/modprobe -sq ${DRIVER}; then
syslog "could not load driver ${DRIVER}!"
beep_error; /bin/rm -f "${LOCK}"; exit 1
fi
# loading firmware
if [ -n "${LOADER}" -a -n "${FIRMWARE}" ]; then
CNT=0 # wait for udev
while [ ! -e /dev/capi20 -a $CNT -lt 20 ]; do
sleep 0.5; : $((CNT++))
done
if [ -f "/lib/firmware/${FIRMWARE}" ]; then
$LOADER $DRIVER $USBDEV $FIRMWARE
else
syslog "firmware ${FIRMWARE} not found!"
beep_error; /bin/rm -f "${LOCK}"; exit 1
fi
fi
# loading capidrv (should be loaded *after* card driver)
if ! ( [ -f /proc/capi/capidrv -o "$CAPI_LOAD_CAPIDRV" != "yes" ] || /sbin/modprobe -sq capidrv ); then
syslog "could not load CAPIDRV!"
fi
beep_ok; /bin/rm -f "${LOCK}"
;;
remove)
/sbin/modprobe -sqr ${DRIVER}
;;
esac
exit 0
|