summaryrefslogtreecommitdiff
path: root/recipes/linux-hotplug/files/sleeve.agent
blob: 55befca1b1649e8df17d67092abed57c35efa3de (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
#!/bin/sh
#
# H3600 Sleeve hotplug policy agent for Linux 2.4 kernels
#
# Kernel NET hotplug params include:
#	
#	ACTION=%s [add or remove]
#	VENDOR_ID=%s
#	DEVICE_ID=%x
#	DEVICE_NAME=%s
#

. /etc/hotplug/hotplug.functions
#DEBUG=yes export DEBUG

if [ "$DEBUG" != "" ]; then
    mesg "Executing $0 action=$ACTION, device=$DEVICE_NAME ($VENDOR_ID,$DEVICE_ID)"
fi

COMPACTFLASH_TIMING_INCREMENT=0
PCMCIA_TIMING_INCREMENT=0
DUAL_PCMCIA_TIMING_INCREMENT=0
NAVMAN_TIMING_INCREMENT=0
BACKPAQ_TIMING_INCREMENT=-100

if [ -f /etc/sysconfig/hotplug ] ; then
    . /etc/sysconfig/hotplug
fi

case $ACTION in
add)
    case $DEVICE_NAME in 
    "Compaq Mercury Backpaq")
	mkdir -p /backpaq
	echo $BACKPAQ_TIMING_INCREMENT > /proc/sys/backpaq/pcmcia/timing_increment_ns
	## mount -t jffs2 /dev/mtdblock/4 /backpaq
	modprobe h3600_backpaq_fpga || mesg 'could not load backpaq fpga driver'
	modprobe h3600_backpaq_camera || mesg 'could not load backpaq camera driver'
	if [ -c /dev/v4l/video0 ] ; then
	    ln -s /dev/v4l/video0 /dev/video0
	    ln -s /dev/v4l/video0 /dev/video
	fi
	CAMERATYPE=`/bin/grep "CameraType" /proc/backpaq/camera | /bin/sed -e 's/.*: //'`
	BACKPAQ_NUMBER=`/bin/grep "Major revision" /proc/backpaq/eeprom | /bin/sed -e 's/.*0x//'`
	FPGA_NUMBER=`/bin/grep "FPGA version" /proc/backpaq/eeprom | /bin/sed -e 's/.*0x//'`
	CAMERA_NUMBER=`/bin/grep "Camera" /proc/backpaq/eeprom | /bin/sed -e 's/.*0x//'`
	
	echo "CAMERA_TYPE = $CAMERATYPE"
	echo "BACKPAQ_NUMBER = $BACKPAQ_NUMBER"
	echo "FPGA_NUMBER = $FPGA_NUMBER"
	echo "CAMERA_NUMBER = $CAMERA_NUMBER"
	echo "looking for file: /etc/fpga_B${BACKPAQ_NUMBER}_F${FPGA_NUMBER}_C${CAMERA_NUMBER}.bin"
	if [ -e /etc/fpga_B${BACKPAQ_NUMBER}_F${FPGA_NUMBER}_C${CAMERA_NUMBER}.bin ] ; then
		    cat /etc/fpga_B${BACKPAQ_NUMBER}_F${FPGA_NUMBER}_C${CAMERA_NUMBER}.bin > /dev/backpaq/fpga
	elif [ -e /etc/fpga_$CAMERATYPE.bin ] ; then
	    cat /etc/fpga_$CAMERATYPE.bin > /dev/backpaq/fpga
	elif [ -e /etc/fpga.bin ] ; then
	    cat /etc/fpga.bin > /dev/backpaq/fpga
	else
	    mesg 'unable to program the backpaq fpga'
	fi
	modprobe h3600_backpaq_accel || mesg 'could not load backpaq accelerometer driver'
	mesg 'BackPAQ drivers loaded'
	;;
    "Compaq CompactFlash Sleeve")
	mesg 'CompactFlash drivers loaded'
	echo $COMPACTFLASH_TIMING_INCREMENT > /proc/sys/bus/pcmcia/timing_increment_ns
	;;
    "Compaq PC Card Sleeve")
	mesg 'PC card sleeve drivers loaded'
	echo $PCMCIA_TIMING_INCREMENT > /proc/sys/bus/pcmcia/timing_increment_ns
	;;
    "Compaq Dual PC Card Sleeve")
	mesg 'Dual PC card sleeve drivers loaded'
	echo $DUAL_PCMCIA_TIMING_INCREMENT > /proc/sys/bus/pcmcia/timing_increment_ns
	;;
    "Navman GPS/CF Sleeve")
	mesg 'Navman GPS sleeve drivers loaded'
	echo $NAVMAN_TIMING_INCREMENT > /proc/sys/bus/pcmcia/timing_increment_ns
	start-stop-daemon --start --exec /usr/sbin/gpsd.bin -- -p /dev/tts/0 -s 57600
	;;
    *)
	mesg "$1 $ACTION event not handled for $DEVICE_NAME"
	;;
    esac
    ;;

remove)
    case $DEVICE_NAME in 
    "Compaq Mercury Backpaq")
	mesg 'Unloading BackPAQ drivers'
	## umount /backpaq
	rmmod h3600_backpaq_camera
	rmmod h3600_backpaq_accel
	rmmod h3600_backpaq_fpga
	;;
    "Compaq CompactFlash Sleeve")
	mesg 'Unloading CompactFlash sleeve'
	;;
    "Compaq PC Card Sleeve")
	mesg 'Unloading PC Card sleeve'
	;;
    "Compaq Dual PC Card Sleeve")
	mesg 'Unloading Dual PC Card sleeve'
	;;
    "Navman GPS/CF Sleeve")
	mesg 'Unloading Navman GPS sleeve'
	start-stop-daemon --stop --name gpsd.bin
	;;
    *)
	mesg $1 $ACTION event not handled for $DEVICE_NAME
	;;
    esac
    ;;

*)
    mesg "$1 $ACTION event not supported"
    exit 1 ;;

esac