Launch hid2hci from udev rules dynamically.
Subsystems (2)
PATCH 3/3 Launch hid2hci from udev rules dynamically.
Rather than launching hid2hci upon every boot even when the user doesn't have hardware that needs it installed, launch it from a set of udev rules that matches the hardware by attributes.
--- scripts/Makefile.am | 9 ++++++++- scripts/bluetooth.default | 3 --- scripts/bluetooth.init | 7 ------- scripts/hid2hci.rules | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 scripts/hid2hci.rules
Signature · 3 lines
Mario Limonciello *Dell | Linux Engineering* [email protected]
From cde70b37b15cc2c41e97e3e307607a980809a5cf Mon Sep 17 00:00:00 2001
From: Mario Limonciello <[email protected]>
Date: Fri, 15 May 2009 17:02:56 -0500
Subject: [PATCH] Launch hid2hci from udev rules dynamically.
Rather than launching hid2hci upon every boot even when the user doesn't have hardware that needs it installed, launch it from a set of udev rules that matches the hardware by attributes.
--- scripts/Makefile.am | 9 ++++++++- scripts/bluetooth.default | 3 --- scripts/bluetooth.init | 7 ------- scripts/hid2hci.rules | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 scripts/hid2hci.rules
scripts/Makefile.am +8 -1
@@ -9,7 +9,14 @@ udevdir = $(libexecdir)/udev udev_SCRIPTS = bluetooth_serial endif -EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default +if HID2HCI +hid2hcidir = $(sysconfdir)/udev + +hid2hci_DATA = hid2hci.rules + +endif + +EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default hid2hci.rules MAINTAINERCLEANFILES = Makefile.in
scripts/bluetooth.default +0 -3
@@ -1,4 +1 @@ # Bluetooth configuraton file - -# Run hid2hci (allowed values are "true" and "false") -HID2HCI_ENABLE=true
scripts/bluetooth.init +0 -7
@@ -10,13 +10,10 @@ NAME=bluetooth DESC="Bluetooth subsystem" DAEMON_NAME=bluetoothd -HID2HCI_NAME=hid2hci DAEMON_EXEC="`which $DAEMON_NAME || true`" -HID2HCI_EXEC="`which $HID2HCI_NAME || true`" DAEMON_ENABLE=true -HID2HCI_ENABLE=false [ -e /etc/default/bluetooth ] && . /etc/default/bluetooth
@@ -27,10 +24,6 @@ case "$1" in $DAEMON_EXEC echo -n " $DAEMON_NAME" fi - if $HID2HCI_ENABLE && [ -x "$HID2HCI_EXEC" ] ; then - $HID2HCI_EXEC --tohci > /dev/null 2>&1 || true - echo -n " $HID2HCI_NAME" - fi echo "." ;; stop)
scripts/hid2hci.rules new file +38 -0
@@ -0,0 +1,38 @@ +#UDEV Rules to match on Bluetooth USB dongles that need to be switched to HCI mode upon +#being plugged into the PC's USB bus. + +##Variety of Dell Bluetooth adapters +# it looks like a bit of an odd rule, because it is matching +# on a mouse device that is self powered, but that is where +# a HID report needs to be sent to switch modes. +#Known supported devices: +# 413c:8154 +# 413c:8158 +# 413c:8162 +ACTION=="add", ENV{ID_VENDOR}=="413c", ENV{ID_CLASS}=="mouse", ATTRS{bmAttributes}=="e0", KERNEL=="mouse*", RUN+="/usr/sbin/hid2hci --method dell -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" + +##Logitech adapters +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c703" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c704" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c705" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70a" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70e" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c713" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c714" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" + +##CSR adapters +#These rules are for csr adapters to default them to hci mode +ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" +ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci" + +#These rules are for csr adapters to default them to hid mode +#ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="0001" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid" +#ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="003f" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid" +#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8203" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid" +#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8204" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid" +#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8207" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
Signature · 1 line
1.6.0.4
Marcel Holtmann
maintainerHi Mario,
Quoted 11 lines
Rather than launching hid2hci upon every boot even when the user
doesn't have hardware that needs it installed, launch it from a set of udev rules that matches the hardware by attributes.--- scripts/Makefile.am | 9 ++++++++- scripts/bluetooth.default | 3 --- scripts/bluetooth.init | 7 ------- scripts/hid2hci.rules | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 scripts/hid2hci.rules
I had to redo the whole thing, but should be working :)
Regards
Marcel