Package: irda-utils Severity: wishlist Tags: patch On x86 and amd64 laptops (and possibly some desktops), the presence of IrDA ports is indicated through the PNP BIOS. The attached patch attempts to use this information to automatically load the correct FIR driver and to configure the serial port appropriately. If successful, it will then start irattach.
-- System Information: Debian Release: 3.1 Architecture: i386 (i586) Kernel: Linux 2.6.8-2-386 Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
diff -urN irda-utils-0.9.16/debian/config irda-utils-0.9.16.mine/debian/config --- irda-utils-0.9.16/debian/config 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/config 2005-08-22 00:43:33 +0100 @@ -15,19 +15,22 @@ # preinst has to retrieve the old values first. if [ ! -e "$CONFIG_OLD" ]; then STATE=1 - LASTSTATE=4 + LASTSTATE=5 while [ $STATE -gt 0 -a $STATE -le $LASTSTATE ]; do case $STATE in 1) db_input medium $PACKAGE/enable || true ;; - 2) + 2) + db_input medium $PACKAGE/automatic || true + ;; + 3) db_input medium $PACKAGE/discovery || true ;; - 3) + 4) db_input medium $PACKAGE/selectdevice || true ;; - 4) + 5) db_get $PACKAGE/selectdevice if [ "$RET" = "serial" ]; then db_input medium $PACKAGE/ttydev || true diff -urN irda-utils-0.9.16/debian/irda-utils.init irda-utils-0.9.16.mine/debian/irda-utils.init --- irda-utils-0.9.16/debian/irda-utils.init 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/irda-utils.init 2005-08-22 00:17:29 +0100 @@ -20,6 +20,14 @@ if [ -f /etc/default/$PACKAGE ]; then . /etc/default/$PACKAGE fi + + +test "$AUTOMATIC" = "true" && if [ -f /var/run/irdadev ]; then +# We discovered a device on boot. Attempt to bind to it. + ENABLE="true" + read -d " " DEVICE </var/run/irdadev +fi + test "$ENABLE" = "false" && exit 0 if [ -z "$DEVICE" ]; then DEVICE="/dev/ttyS1" diff -urN irda-utils-0.9.16/debian/irda-utils.irda-setup.init irda-utils-0.9.16.mine/debian/irda-utils.irda-setup.init --- irda-utils-0.9.16/debian/irda-utils.irda-setup.init 1970-01-01 01:00:00 +0100 +++ irda-utils-0.9.16.mine/debian/irda-utils.irda-setup.init 2005-08-22 00:23:58 +0100 @@ -0,0 +1,95 @@ +#!/bin/bash + +. /etc/default/irda-utils + +test "$AUTOMATIC" = "true" || exit 0 + +test -d /sys/bus/pnp/devices || exit 0 + +cd /sys/bus/pnp/devices + +IRDA=0; +STATEFILE=/var/run/irdadev; + +case $1 in + start|restart|reload|force-reload) + for x in *; do + FIR="false"; + SIR="false"; + FALLBACK=true; + OPTIONS="" + for y in `cat $x/id`; do + case "$y" in + PNP0510|PNP0511) + SIR="true"; + ;; + NSC*) + FIR="nsc-ircc"; + ;; + IBM0071) + FIR="nsc-ircc"; + OPTIONS="dongle_id=0x09"; + ;; + SMC*) + FIR="smsc-ircc2"; + ;; + esac + done + + # Work out resource ranges, so we know which serial port to work with + PORT=`grep io $x/resources | sed -e 's/io \(.*\)-.*/\1/'` + case $PORT in + 0x3f8) + PORT="/dev/ttyS0" + ;; + 0x2f8) + PORT="/dev/ttyS1" + ;; + 0x3e8) + PORT="/dev/ttyS2" + ;; + 0x2e8) + PORT="/dev/ttyS3" + ;; + default) + PORT="UNKNOWN" + ;; + esac; + + + if [ "$FIR" != "false" ]; then + UART="unknown"; + if [ "$PORT" != "UNKNOWN" ]; then + # We should attempt to disable the UART. However, we need to store + # it - there's a chance that things could still go horribly wrong + UART=`setserial $PORT | sed 's/.*UART: \(.*\), Port.*/\1/'` + setserial $PORT uart none + fi + modprobe $FIR $OPTIONS; + if [ "$?" = "0" ]; then + echo "irda$IRDA fir" >$STATEFILE; + let "IRDA=$IRDA+1"; + FALLBACK=false; + else + # Try to recover + if [ "$UART" != "undefined" ]; then + setserial $PORT uart $UART; + fi + fi + fi + + if [ "$SIR" = "true" ]; then + if [ "$FIR" = "false" -o "$FALLBACK" = "true" ]; then + # Ok, let's try just driving the UART + # The IRQ is not always set correctly, so try to deal with that + IRQ=`grep irq $x/resources | sed -e 's/irq \(.*\)/\1/'` + setserial $PORT irq $IRQ; + echo "$PORT sir" >$STATEFILE; + fi + fi + done + ;; + stop) + exit 0 + ;; +esac diff -urN irda-utils-0.9.16/debian/po/de.po irda-utils-0.9.16.mine/debian/po/de.po --- irda-utils-0.9.16/debian/po/de.po 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/po/de.po 2005-08-22 00:36:36 +0100 @@ -15,7 +15,7 @@ msgstr "" "Project-Id-Version: irda-utils\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-07-24 10:17+0200\n" +"POT-Creation-Date: 2005-08-22 00:36+0100\n" "PO-Revision-Date: 2004-05-21 14:23+0200\n" "Last-Translator: Sebastian Henschel <[EMAIL PROTECTED]>\n" "Language-Team: de <[EMAIL PROTECTED]>\n" @@ -179,3 +179,18 @@ "Bestätigen Sie, wenn IrDA während des Bootvorgangs aktiviert werden soll. " "Dies ist für Geräte notwendig, die ein laufendes \"irattach\" benötigen. Die " "meisten Geräte brauchen es, mit Ausnahme einiger weniger FIR-Geräte." + +#. Type: boolean +#. Description +#: ../templates:65 +#, fuzzy +msgid "Attempt to probe for IrDA on system bootup?" +msgstr "Aktiviere IrDA bei Systemstart?" + +#. Type: boolean +#. Description +#: ../templates:65 +msgid "" +"Confirm if you want to attempt to autoconfigure IrDA on system startup. If " +"a device is found, irattach will automatically be started up." +msgstr "" diff -urN irda-utils-0.9.16/debian/po/fr.po irda-utils-0.9.16.mine/debian/po/fr.po --- irda-utils-0.9.16/debian/po/fr.po 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/po/fr.po 2005-08-22 00:36:37 +0100 @@ -17,7 +17,7 @@ msgstr "" "Project-Id-Version: irda-utils\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-07-24 10:17+0200\n" +"POT-Creation-Date: 2005-08-22 00:36+0100\n" "PO-Revision-Date: 2004-07-24 22:00+0200\n" "Last-Translator: Christian Perrier <[EMAIL PROTECTED]>\n" "Language-Team: French <[EMAIL PROTECTED]>\n" @@ -184,3 +184,18 @@ "lancement de votre système. Ce choix est indispensable pour les " "périphériques qui ont besoin de « irattach » pour fonctionner, ce qui est le " "cas de la plupart, à l'exception de rares périphériques FIR." + +#. Type: boolean +#. Description +#: ../templates:65 +#, fuzzy +msgid "Attempt to probe for IrDA on system bootup?" +msgstr "Faut-il activer la gestion de l'infrarouge au démarrage ?" + +#. Type: boolean +#. Description +#: ../templates:65 +msgid "" +"Confirm if you want to attempt to autoconfigure IrDA on system startup. If " +"a device is found, irattach will automatically be started up." +msgstr "" diff -urN irda-utils-0.9.16/debian/po/templates.pot irda-utils-0.9.16.mine/debian/po/templates.pot --- irda-utils-0.9.16/debian/po/templates.pot 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/po/templates.pot 2005-08-22 00:36:37 +0100 @@ -16,7 +16,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-07-24 10:17+0200\n" +"POT-Creation-Date: 2005-08-22 00:36+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n" "Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n" @@ -149,3 +149,17 @@ "necessary for devices that need \"irattach\" to be run. Most devices need " "it, except for some rare FIR devices." msgstr "" + +#. Type: boolean +#. Description +#: ../templates:65 +msgid "Attempt to probe for IrDA on system bootup?" +msgstr "" + +#. Type: boolean +#. Description +#: ../templates:65 +msgid "" +"Confirm if you want to attempt to autoconfigure IrDA on system startup. If " +"a device is found, irattach will automatically be started up." +msgstr "" diff -urN irda-utils-0.9.16/debian/postinst irda-utils-0.9.16.mine/debian/postinst --- irda-utils-0.9.16/debian/postinst 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/postinst 2005-08-22 00:32:46 +0100 @@ -104,6 +104,10 @@ # to 'true'. ENABLE= +# Set this to 'false' if you do not want automatic discovery of irda devices. +# If 'true', it will automatically start irattach if devices are found. +AUTOMATIC= + # Set discovery mode which usually is a good idea for finding other devices. DISCOVERY= @@ -127,6 +131,8 @@ # read config db_get $PACKAGE/enable ENABLE="$RET" + db_get $PACKAGE/automatic + AUTOMATIC="$RET" db_get $PACKAGE/discovery DISCOVERY="$RET" if [ "$DEVICE" = "serial" ]; then @@ -145,6 +151,7 @@ # re-insert values deleted in $CONFIG but existant in debconf test -z "$ENABLE" || grep -Eq '^ *ENABLE=' $CONFIG || echo "ENABLE=" >> $CONFIG + test -z "$AUTOMATIC" || grep -Eq '^ *AUTOMATIC=' $CONFIG || echo "AUTOMATIC=" >> $CONFIG test -z "$DISCOVERY" || grep -Eq '^ *DISCOVERY=' $CONFIG || echo "DISCOVERY=" >> $CONFIG test -z "$DEVICE" || grep -Eq '^ *DEVICE=' $CONFIG || echo "DEVICE=" >> $CONFIG test -z "$DONGLE" || grep -Eq '^ *DONGLE=' $CONFIG || echo "DONGLE=" >> $CONFIG @@ -154,6 +161,7 @@ # all comments and other variables defined by the admin sed -e " s#^ *ENABLE=.*#ENABLE=\"$ENABLE\"# + s#^ *AUTOMATIC=.*#AUTOMATIC=\"$AUTOMATIC\"# s#^ *DISCOVERY=.*#DISCOVERY=\"$DISCOVERY\"# s#^ *DEVICE=.*#DEVICE=\"$DEVICE\"# s#^ *DONGLE=.*#DONGLE=\"$DONGLE\"# diff -urN irda-utils-0.9.16/debian/preinst irda-utils-0.9.16.mine/debian/preinst --- irda-utils-0.9.16/debian/preinst 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/preinst 2005-08-22 00:42:21 +0100 @@ -89,6 +89,8 @@ # store values from current config db_set $PACKAGE/enable $ENABLE + db_set $PACKAGE/automatic $AUTOMATIC + case "$DEVICE" in /dev/ttyS*) db_set $PACKAGE/selectdevice serial diff -urN irda-utils-0.9.16/debian/rules irda-utils-0.9.16.mine/debian/rules --- irda-utils-0.9.16/debian/rules 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/rules 2005-08-22 00:35:34 +0100 @@ -105,6 +105,7 @@ # dh_installmenu # dh_installemacsen dh_installinit + dh_installinit -r --no-start --name=irda-setup -- start 47 S . # dh_installcron dh_installdebconf if [ "$(DEB_BUILD_GNU_TYPE)" = "i386-linux" ]; then \ diff -urN irda-utils-0.9.16/debian/templates irda-utils-0.9.16.mine/debian/templates --- irda-utils-0.9.16/debian/templates 2005-08-22 00:40:35 +0100 +++ irda-utils-0.9.16.mine/debian/templates 2005-08-22 00:34:30 +0100 @@ -58,3 +58,10 @@ Confirm if you want IrDA to be enabled when your system is booting. This is necessary for devices that need "irattach" to be run. Most devices need it, except for some rare FIR devices. + +Template: irda-utils/automatic +Type: boolean +Default: true +_Description: Attempt to probe for IrDA on system bootup? + Confirm if you want to attempt to autoconfigure IrDA on system startup. If + a device is found, irattach will automatically be started up.