vanhofen
7 years ago
11 changed files with 283 additions and 133 deletions
@ -1,82 +0,0 @@ |
|||
#!/bin/sh |
|||
LOG="/bin/logger -p user.info -t mdev-usb" |
|||
WARN="/bin/logger -p user.warn -t mdev-usb" |
|||
|
|||
flagLCD=/tmp/.lcd-${MDEV} |
|||
|
|||
# supported dpf-devices |
|||
DPF="1908:0102" |
|||
|
|||
# supported spf-devices |
|||
SPFstorage="04E8:200A 04E8:200E 04E8:200C 04E8:2012 04E8:2016 04E8:2025 04E8:2033 04E8:201C 04E8:2027 04E8:2035 04E8:204F 04E8:2039" |
|||
SPFmonitor="04E8:200B 04E8:200F 04E8:200D 04E8:2013 04E8:2017 04E8:2026 04E8:2034 04E8:201B 04E8:2028 04E8:2036 04E8:2050 04E8:2040" |
|||
# SPFmodel: ^SPF-72H ^SPF-75H ^SPF-83H ^SPF-85H ^SPF-85P ^SPF-87H ^SPF-87H ^SPF-105P ^SPF-107H ^SPF-107H ^SPF-700T ^SPF-1000P |
|||
# SPFmodel: ^SPF-76H ^SPF-86H ^SPF-86P old new |
|||
SPF="${SPFstorage} ${SPFmonitor}" |
|||
|
|||
DEVICES="${DPF} ${SPF}" |
|||
for DEVICE in ${DEVICES}; do |
|||
V=$(echo ${DEVICE:0:4} | sed 's/^[0]*//' | tr [:upper:] [:lower:]) # lower case vendor w/o leading zeros |
|||
P=$(echo ${DEVICE:5:4} | sed 's/^[0]*//' | tr [:upper:] [:lower:]) # lower case product w/o leading zeros |
|||
|
|||
case "$ACTION" in |
|||
add|"") |
|||
#$LOG "trying to process ${DEVICE} (V:{$V} P:{$P}) on ${MDEV}" |
|||
|
|||
uevent=/sys/class/usb_device/${MDEV}/device/uevent |
|||
|
|||
test -e $uevent || continue |
|||
grep "^PRODUCT=${V}/${P}/*" $uevent >/dev/null || continue |
|||
|
|||
$LOG "supported device (ID ${DEVICE}) on ${MDEV} found" |
|||
|
|||
# dpf/spf-support |
|||
if $(echo "${DPF} ${SPF}" | grep -q "${DEVICE}"); then |
|||
$LOG "creating flagfile '$flagLCD'" |
|||
echo "${DEVICE}" > $flagLCD |
|||
|
|||
if $(echo "${DPF} ${SPFstorage}" | grep -q "${DEVICE}"); then |
|||
$LOG "DPF or SPF in storage mode found" |
|||
$LOG "(re)starting lcd4linux" |
|||
|
|||
service lcd4linux restart |
|||
fi |
|||
|
|||
if $(echo "${SPFmonitor}" | grep -q "${DEVICE}"); then |
|||
$LOG "SPF in monitor mode found" |
|||
if [ -e /tmp/lcd4linux.pid ]; then |
|||
$LOG "do nothing" |
|||
else |
|||
$LOG "(re)starting lcd4linux" |
|||
service lcd4linux restart |
|||
fi |
|||
fi |
|||
fi |
|||
;; |
|||
remove) |
|||
#$LOG "trying to process ${DEVICE} (V:{$V} P:{$P}) on ${MDEV}" |
|||
|
|||
# dpf/spf-support |
|||
if [ -e $flagLCD ]; then |
|||
grep "^${DEVICE}" $flagLCD >/dev/null || continue |
|||
|
|||
$LOG "supported DPF/SPF (ID ${DEVICE}) removed from ${MDEV}" |
|||
|
|||
if $(echo "${DPF} ${SPFmonitor}" | grep -q "${DEVICE}"); then |
|||
$LOG "DPF or SPF in monitor mode removed" |
|||
$LOG "stopping lcd4linux" |
|||
|
|||
service lcd4linux stop |
|||
fi |
|||
|
|||
if $(echo "${SPFstorage}" | grep -q "${DEVICE}"); then |
|||
$LOG "SPF in storage mode removed" |
|||
$LOG "do nothing" |
|||
fi |
|||
|
|||
$LOG "removing flagfile '$flagLCD'" |
|||
rm -f $flagLCD |
|||
fi |
|||
;; |
|||
esac |
|||
done |
@ -1,18 +0,0 @@ |
|||
#!/bin/sh |
|||
LOG="logger -p user.info -t mdev-wlan" |
|||
WARN="logger -p user.warn -t mdev-wlan" |
|||
|
|||
case "$ACTION" in |
|||
add|"") |
|||
if [ -s /etc/wpa_supplicant.conf ]; then |
|||
$LOG "trying to bring $MDEV up" |
|||
ifup $MDEV |
|||
else |
|||
$WARN "/etc/wpa_supplicant.conf missing or empty, not trying to bring $MDEV up" |
|||
fi |
|||
;; |
|||
remove) |
|||
$LOG "trying to bring $MDEV down" |
|||
ifdown $MDEV |
|||
;; |
|||
esac |
@ -0,0 +1,33 @@ |
|||
#!/bin/sh |
|||
# vim: se ft=sh: |
|||
|
|||
log_debug () { |
|||
logger -t "${0##*/}[$$]" -p local0.debug "$@" |
|||
} |
|||
log_error () { |
|||
logger -t "${0##*/}[$$]" -p local0.error "$@" |
|||
} |
|||
log_info () { |
|||
logger -t "${0##*/}[$$]" -p local0.info "$@" |
|||
} |
|||
|
|||
log_warn () { |
|||
logger -t "${0##*/}[$$]" -p local0.warn "$@" |
|||
} |
|||
|
|||
# can't get the return code from a piped process |
|||
# cat /etc/passwd | log_error => $? is from log_error not cat ;( |
|||
log_rt_error () { |
|||
local fifo=/tmp/.log_rt_error_$$ |
|||
trap "trap - HUP QUIT TERM CHLD; log_error exited prematurely; rm -f $fifo; exit 1" \ |
|||
HUP QUIT TERM |
|||
mkfifo -m 600 $fifo |
|||
|
|||
trap "trap - HUP QUIT TERM CHLD; rm -f $fifo" CHLD |
|||
log_error <$fifo & |
|||
"$@" 2>$fifo |
|||
} |
|||
|
|||
log_clean () { |
|||
unset -f log_debug log_error log_info log_rt_error |
|||
} |
@ -0,0 +1,7 @@ |
|||
#!/bin/sh |
|||
|
|||
# log only when requested |
|||
[ 0 -eq $# ] && exit 0 |
|||
|
|||
. /lib/mdev/common/log |
|||
env | egrep -v '^(HOME|PATH|PWD|CONFIG_.*)=' | log_debug |
@ -0,0 +1,5 @@ |
|||
#!/bin/sh |
|||
|
|||
. /lib/mdev/common/log |
|||
log_info "${ACTION:-scan} module chain $@" |
|||
/lib/mdev/common/mdevprobe "$@" |
@ -0,0 +1,9 @@ |
|||
#!/bin/sh |
|||
|
|||
[ "$ACTION" = remove ] && action='-r -a' |
|||
|
|||
. /lib/mdev/common/log |
|||
for module in "$@"; do |
|||
modprobe $action $module && |
|||
log_info "${ACTION:-scan} module $module succeed" |
|||
done |
@ -0,0 +1,19 @@ |
|||
#!/bin/sh |
|||
|
|||
. /lib/mdev/common/log |
|||
|
|||
case "$ACTION" in |
|||
add|"") |
|||
if [ -s /etc/wpa_supplicant.conf ]; then |
|||
log_info "trying to bring $MDEV up" |
|||
ifup $MDEV |
|||
else |
|||
log_warn "/etc/wpa_supplicant.conf missing or empty, not trying to bring $MDEV up" |
|||
fi |
|||
;; |
|||
|
|||
remove) |
|||
log_info "trying to bring $MDEV down" |
|||
ifdown $MDEV |
|||
;; |
|||
esac |
@ -0,0 +1,32 @@ |
|||
#!/bin/false |
|||
# vim: se ft=sh: |
|||
|
|||
for path in $(find /sys/devices -name "$MDEV" 2>/dev/null); do |
|||
DEVPATH=${path#/sys} |
|||
done |
|||
|
|||
MODALIAS=$(cat /sys${DEVPATH}/modalias 2>/dev/null) |
|||
|
|||
parse_interface () { |
|||
printf '%d/%d/%d' $(sed 's/.*dp[0-F]\{2\}//;s/[iscp]\+/ 0x/g') |
|||
} |
|||
parse_type () { |
|||
printf '%d/%d/%d' $(sed 's/.*d[0-9]\{4\}//;s/ic.*//;s/[dscp]\+/ 0x/g') |
|||
} |
|||
parse_product () { |
|||
sed 's!^usb:\(.*\)dc.*!\1!;s![vpd]!/!g;s!/0\{1,3\}!/!g;s!^/!!;y!ABCDEF!abcdef!' |
|||
} |
|||
|
|||
TYPE=$(echo $MODALIAS | parse_type) |
|||
PRODUCT=$(echo $MODALIAS | parse_product) |
|||
INTERFACE=$(echo $MODALIAS | parse_interface) |
|||
|
|||
for var in DEVPATH MODALIAS TYPE PRODUCT INTERFACE; do |
|||
if [ -z "$(eval "echo \$${var}")" ]; then |
|||
logerror "Could not set uevent environment variable $var" |
|||
exit 1 |
|||
fi |
|||
done |
|||
|
|||
unset path var |
|||
unset -f parse_type parse_interface parse_product |
@ -0,0 +1,119 @@ |
|||
#!/bin/sh |
|||
|
|||
. /lib/mdev/common/log |
|||
|
|||
# setup environment for cold plug events |
|||
[ -z "$ACTION" ] && . /lib/mdev/usb/eventvars |
|||
|
|||
# get proper product and manufacturer description (only works for ACTION=add) |
|||
[ -z "$DEVPATH" ] && logerror 'uevent environment variable DEVPATH is unset' && exit 1 |
|||
if [ -d /sys${DEVPATH} ]; then |
|||
cd /sys${DEVPATH}/.. |
|||
for f in product manufacturer id[PV]*; do |
|||
[ -r $f ] && eval "$f='$(cat $f)'" |
|||
done |
|||
cd $MDEV |
|||
fi |
|||
|
|||
# get $idVendor and $idProduct from $MODALIAS if necessary |
|||
idVendor=${idVendor:-${MODALIAS:5:4}} |
|||
idProduct=${idProduct:-${MODALIAS:10:4}} |
|||
# set $idVendor and $idProduct lower case and w/o leading zeros |
|||
idVendor=$(echo ${idVendor} | sed 's/^[0]*//' | tr [:upper:] [:lower:]) |
|||
idProduct=$(echo ${idProduct} | sed 's/^[0]*//' | tr [:upper:] [:lower:]) |
|||
|
|||
channel=${MDEV%:1.0} |
|||
log_info "${ACTION} $channel ${manufacturer:-$idVendor} ${product:-$idProduct}" |
|||
|
|||
# for debug |
|||
#log_info "ACTION=${ACTION}" |
|||
#log_info "MDEV=${MDEV}" |
|||
#log_info "DEVPATH=${DEVPATH}" |
|||
#log_info "INTERFACE=${INTERFACE}" |
|||
#log_info "MODALIAS=${MODALIAS}" |
|||
#log_info "PRODUCT=${product} idProduct=${idProduct}" |
|||
#log_info "MANUFACTURER=${manufacturer} idVendor=${idVendor}" |
|||
|
|||
# http://en.wikipedia.org/wiki/Universal_Serial_Bus#Device_classes |
|||
# http://www.usb.org/developers/defined_class |
|||
[ 0 -eq "${TYPE%%/*}" ] && TYPE=$INTERFACE |
|||
log_info "type ${TYPE}" |
|||
case $TYPE in |
|||
1/*/*) |
|||
log_info "$channel USB Audio Interface" |
|||
;; |
|||
2/*/*) |
|||
log_info "$channel Communications and CDC Control" |
|||
;; |
|||
3/*/*) |
|||
log_info "$channel HID (Human Interface Device)" |
|||
# precheck vendor id for unsupported DPF in bootloader mode |
|||
if [ "$idVendor" == "1908" ]; then |
|||
service extdisplay ${ACTION} ${MDEV} ${idVendor} ${idProduct} |
|||
fi |
|||
;; |
|||
5/*/*) |
|||
log_info "$channel Physical Interface" |
|||
;; |
|||
6/*/*) |
|||
log_info "$channel Image Interface" |
|||
;; |
|||
7/*/*) |
|||
log_info "$channel Printer Interface" |
|||
;; |
|||
8/*/*) |
|||
log_info "$channel Mass Storage Interface" |
|||
# precheck vendor id for supported SPFs |
|||
if [ "$idVendor" == "4e8" ]; then |
|||
service extdisplay ${ACTION} ${MDEV} ${idVendor} ${idProduct} |
|||
fi |
|||
;; |
|||
9/*/*) |
|||
log_info "$channel HUB Device" |
|||
;; |
|||
10/*/*) |
|||
log_info "$channel CDC Data Interface" |
|||
;; |
|||
11/*/*) |
|||
log_info "$channel Smart Card Interface" |
|||
;; |
|||
13/*/*) |
|||
log_info "$channel Content Security Interface" |
|||
;; |
|||
14/*/*) |
|||
log_info "$channel Video Interface" |
|||
;; |
|||
15/*/*) |
|||
log_info "$channel Personal Healthcare Interface" |
|||
;; |
|||
16/*/*) |
|||
log_info "$channel usb Audio/Video Devices Interface" |
|||
;; |
|||
17/*/*) |
|||
log_info "$channel Billboard Device Class" |
|||
;; |
|||
220/*/*) |
|||
log_info "$channel Diagnostic Device" |
|||
;; |
|||
224/*/*) |
|||
log_info "$channel Wireless Controller Interface" |
|||
;; |
|||
239/*/*) |
|||
log_info "$channel Miscellaneous" |
|||
;; |
|||
254/*/*) |
|||
log_info "$channel Application Specific" |
|||
;; |
|||
255/*/*) |
|||
log_info "$channel Vendor Specific" |
|||
# precheck vendor id for supported DPFs and SPFs |
|||
if [ "$idVendor" = "1908" -o "$idVendor" == "4e8" ]; then |
|||
service extdisplay ${ACTION} ${MDEV} ${idVendor} ${idProduct} |
|||
fi |
|||
;; |
|||
*) |
|||
log_info "FALLBACK: $channel device $MODALIAS" |
|||
;; |
|||
esac |
|||
|
|||
/lib/mdev/common/mdevprobe $MODALIAS |
Loading…
Reference in new issue