[PATCH 3/3] Launch hid2hci from udev rules dynamically.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 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

-- 
Mario Limonciello
*Dell | Linux Engineering*
mario_limonciello@xxxxxxxx
From cde70b37b15cc2c41e97e3e307607a980809a5cf Mon Sep 17 00:00:00 2001
From: Mario Limonciello <Mario_Limonciello@xxxxxxxx>
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

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 6a8eec7..2dc754a 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -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
 
diff --git a/scripts/bluetooth.default b/scripts/bluetooth.default
index b0c4493..cdf37fa 100644
--- a/scripts/bluetooth.default
+++ b/scripts/bluetooth.default
@@ -1,4 +1 @@
 # Bluetooth configuraton file
-
-# Run hid2hci (allowed values are "true" and "false")
-HID2HCI_ENABLE=true
diff --git a/scripts/bluetooth.init b/scripts/bluetooth.init
index ee12408..3ea8a89 100644
--- a/scripts/bluetooth.init
+++ b/scripts/bluetooth.init
@@ -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)
diff --git a/scripts/hid2hci.rules b/scripts/hid2hci.rules
new file mode 100644
index 0000000..37bbe4b
--- /dev/null
+++ b/scripts/hid2hci.rules
@@ -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"
-- 
1.6.0.4

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux