Skip to contentSkip to conversation

Run hid2hci after resuming from suspend

PATCH In review Mario Limonciello 3 participants 4 messages Oct 22, 2008 – Oct 24, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Run hid2hci after resuming from suspend

Hello,

This patch adds support for the hid2hci command to be ran upon resuming from suspend. At least the USB adapters I've been operating with that need to switch modes need to do so upon resume.

Regards

Signature · 3 lines
Mario Limonciello
*Dell | Linux Engineering*
[email protected]
scripts/hid2hci.pm-utils +24 -0
diff -Nur -x '*.orig' -x '*~' bluez-4.12/scripts/hid2hci.pm-utils bluez-4.12.new/scripts/hid2hci.pm-utils
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Switch all devices that were in a HID mode to HCI mode
+# after a resume
+
+. "${PM_FUNCTIONS}"
+
+[ -f /etc/default/bluetooth ] || exit $NA
+
+. /etc/default/bluetooth
+
+hid2hci()
+{
+	if [ "$HID2HCI_ENABLED" = "1" ] && [ -x /usr/sbin/hid2hci ]; then
+		/usr/sbin/hid2hci --tohci
+        fi
+}
+
+case "$1" in
+	thaw|resume)
+		hid2hci
+		;;
+	*) exit $NA
+		;;
+esac
scripts/Makefile.am +10 -1
diff -Nur -x '*.orig' -x '*~' bluez-4.12/scripts/Makefile.am bluez-4.12.new/scripts/Makefile.am
@@ -9,7 +9,7 @@
 udev_SCRIPTS = bluetooth_serial
 endif
 
-EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default
+EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default hid2hci.pm-utils
 
 MAINTAINERCLEANFILES = Makefile.in
 
@@ -24,3 +24,12 @@
 	@rm -f $(DESTDIR)$(sysconfdir)/init.d/bluetooth
 	@rm -f $(DESTDIR)$(sysconfdir)/default/bluetooth
 endif
+
+if HID2HCI
+install-data-local:
+	$(mkinstalldirs) $(DESTDIR)/$(libexecdir)/pm-utils/sleep.d
+	$(INSTALL) -D -m 744 $(srcdir)/hid2hci.pm-utils $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48hid2hci
+
+uninstall-local:
+	@rm -f $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48hid2hci
+endif
scripts/Makefile.in +10 -1
diff -Nur -x '*.orig' -x '*~' bluez-4.12/scripts/Makefile.in bluez-4.12.new/scripts/Makefile.in
@@ -192,7 +192,7 @@
 @PCMCIARULES_TRUE@rules_DATA = bluetooth.rules
 @PCMCIARULES_TRUE@udevdir = $(libexecdir)/udev
 @PCMCIARULES_TRUE@udev_SCRIPTS = bluetooth_serial
-EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default
+EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default hid2hci.pm-utils
 MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
@@ -335,6 +335,8 @@
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
 @INITSCRIPTS_FALSE@uninstall-local:
 @INITSCRIPTS_FALSE@install-data-local:
+@HID2HCI_FALSE@uninstall-local:
+@HID2HCI_FALSE@install-data-local:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool mostlyclean-am
@@ -416,6 +418,13 @@
 @INITSCRIPTS_TRUE@uninstall-local:
 @INITSCRIPTS_TRUE@	@rm -f $(DESTDIR)$(sysconfdir)/init.d/bluetooth
 @INITSCRIPTS_TRUE@	@rm -f $(DESTDIR)$(sysconfdir)/default/bluetooth
+
+@HID2HCI_TRUE@install-data-local:
+@HID2HCI_TRUE@	$(mkinstalldirs) $(DESTDIR)/$(libexecdir)/pm-utils/sleep.d
+@HID2HCI_TRUE@	$(INSTALL) -D -m 744 $(srcdir)/hid2hci.pm-utils $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48hid2hci
+
+@HID2HCI_TRUE@uninstall-local:
+@HID2HCI_TRUE@	@rm -f $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48hid2hci
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
maintainer
#1 lore raw

Hi Mario,

Quoted 3 lines

This patch adds support for the hid2hci command to be ran upon resuming from suspend. At least the USB adapters I've been operating with that need to switch modes need to do so upon resume.

we should not install multiple scripts. Lets only install one "bluez" file for pm-utils. So no need for a hid2hci specific script.

Regards

Marcel

#2 lore raw

Hi Marcel:

Quoted 9 lines · Marcel Holtmann

Hi Mario,

we should not install multiple scripts. Lets only install one "bluez" file for pm-utils. So no need for a hid2hci specific script.

Regards

Marcel

Attached is an updated patch that will install this as "48bluez" for pm-utils. Of course the only thing in it right now is hid2hci, but should that need to change, it's easy to add more.

Regards

Signature · 3 lines
Mario Limonciello
*Dell | Linux Engineering*
[email protected]
scripts/bluetooth.pm-utils +24 -0
diff -Nur -x '*.orig' -x '*~' bluez-4.12/scripts/bluetooth.pm-utils bluez-4.12.new/scripts/bluetooth.pm-utils
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Switch all devices that were in a HID mode to HCI mode
+# after a resume
+
+. "${PM_FUNCTIONS}"
+
+[ -f /etc/default/bluetooth ] || exit $NA
+
+. /etc/default/bluetooth
+
+hid2hci()
+{
+	if [ "$HID2HCI_ENABLED" = "1" ] && [ -x /usr/sbin/hid2hci ]; then
+		/usr/sbin/hid2hci --tohci
+        fi
+}
+
+case "$1" in
+	thaw|resume)
+		hid2hci
+		;;
+	*) exit $NA
+		;;
+esac
scripts/Makefile.am +8 -1
diff -Nur -x '*.orig' -x '*~' bluez-4.12/scripts/Makefile.am bluez-4.12.new/scripts/Makefile.am
@@ -9,7 +9,7 @@
 udev_SCRIPTS = bluetooth_serial
 endif
 
-EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default
+EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default bluetooth.pm-utils
 
 MAINTAINERCLEANFILES = Makefile.in
 
@@ -24,3 +24,10 @@
 	@rm -f $(DESTDIR)$(sysconfdir)/init.d/bluetooth
 	@rm -f $(DESTDIR)$(sysconfdir)/default/bluetooth
 endif
+
+install-data-pm:
+	$(mkinstalldirs) $(DESTDIR)/$(libexecdir)/pm-utils/sleep.d
+	$(INSTALL) -D -m 744 $(srcdir)/bluetooth.pm-utils $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48bluez
+
+uninstall-pm:
+	@rm -f $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48bluez
scripts/Makefile.in +11 -2
diff -Nur -x '*.orig' -x '*~' bluez-4.12/scripts/Makefile.in bluez-4.12.new/scripts/Makefile.in
@@ -192,7 +192,7 @@
 @PCMCIARULES_TRUE@rules_DATA = bluetooth.rules
 @PCMCIARULES_TRUE@udevdir = $(libexecdir)/udev
 @PCMCIARULES_TRUE@udev_SCRIPTS = bluetooth_serial
-EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default
+EXTRA_DIST = bluetooth.rules bluetooth_serial bluetooth.init bluetooth.default hid2hci.pm-utils
 MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
@@ -335,6 +335,8 @@
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
 @INITSCRIPTS_FALSE@uninstall-local:
 @INITSCRIPTS_FALSE@install-data-local:
+uninstall-pm:
+install-data-pm:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool mostlyclean-am
@@ -354,7 +356,7 @@
 info-am:
 
 install-data-am: install-data-local install-rulesDATA \
-	install-udevSCRIPTS
+	install-udevSCRIPTS install-data-pm
 
 install-dvi: install-dvi-am
 
@@ -416,6 +418,13 @@
 @INITSCRIPTS_TRUE@uninstall-local:
 @INITSCRIPTS_TRUE@	@rm -f $(DESTDIR)$(sysconfdir)/init.d/bluetooth
 @INITSCRIPTS_TRUE@	@rm -f $(DESTDIR)$(sysconfdir)/default/bluetooth
+
+install-data-pm:
+	$(mkinstalldirs) $(DESTDIR)/$(libexecdir)/pm-utils/sleep.d
+	$(INSTALL) -D -m 744 $(srcdir)/bluetooth.pm-utils $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48bluez
+
+uninstall-pm:
+	@rm -f $(DESTDIR)$(libexecdir)/pm-utils/sleep.d/48bluez
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
#3 lore raw
Quoted 4 lines · Mario Limonciello

+[ -f /etc/default/bluetooth ] || exit $NA
+
+. /etc/default/bluetooth

Wrong file to source under Fedora.

Quoted 2 lines

+ if [ "$HID2HCI_ENABLED" = "1" ] && [ -x /usr/sbin/hid2hci ];
then

$ grep "HID2HCI_ENABLE[D=]" /etc/sysconfig/bluetooth 
#HID2HCI_ENABLE=true

Cheers