From: Mario Limonciello <mario_limonciello@dell.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH 1/2] Add support to hid2hci for recovering Dell BT devices
Date: Thu, 16 Jul 2009 21:37:44 +0000 [thread overview]
Message-ID: <4A5F9DA8.9020508@dell.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 423 bytes --]
Hi:
Attached is the first of two follow up patches to the original thread
titled "Explicitly disable BT radio using rfkill interface on suspend".
This patch adds support for finding the child device to poke. It
addresses previous feedback that more pointers needed to be added to
find_resuscitated_device for readability.
Regards
--
Mario Limonciello
*Dell | Linux Engineering*
mario_limonciello@dell.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: resuscitate.patch --]
[-- Type: text/x-patch; name="resuscitate.patch", Size: 3784 bytes --]
=== modified file 'extras/hid2hci/70-hid2hci.rules'
--- extras/hid2hci/70-hid2hci.rules 2009-06-26 06:17:23 +0000
+++ extras/hid2hci/70-hid2hci.rules 2009-07-15 22:50:01 +0000
@@ -11,6 +11,11 @@
ATTR{bInterfaceClass}=="03", ATTR{bInterfaceSubClass}=="01", ATTR{bInterfaceProtocol}=="02", ATTRS{bDeviceClass}=="00", ATTRS{idVendor}=="413c", ATTRS{bmAttributes}=="e0", \
RUN+="hid2hci --method dell -v $attr{idVendor} -p $attr{idProduct} --mode hci"
+# When a Dell device recovers from S3, the mouse child needs to be repoked
+# Unfortunately the only event seen is the BT device disappearing, so the mouse
+# device needs to be chased down on the USB bus.
+ATTR{bDeviceClass}=="e0", ATTR{bDeviceSubClass}=="01", ATTR{bDeviceProtocol}=="01", ATTR{idVendor}=="413c", ATTR{bmAttributes}=="e0", IMPORT{parent}="ID_*", ENV{REMOVE_CMD}="hid2hci --method dell -v $env{ID_VENDOR_ID} -p $env{ID_MODEL_ID} --mode hci -s 02"
+
ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end"
# Logitech devices
=== modified file 'extras/hid2hci/hid2hci.c'
--- extras/hid2hci/hid2hci.c 2009-06-16 17:30:22 +0000
+++ extras/hid2hci/hid2hci.c 2009-07-15 22:51:01 +0000
@@ -271,6 +271,36 @@
return 0;
}
+static int find_resuscitated_device(struct device_info* devinfo, uint8_t bInterfaceProtocol)
+{
+ int i,j,k,l;
+ struct usb_device *dev, *child;
+ struct usb_config_descriptor config;
+ struct usb_interface interface;
+ struct usb_interface_descriptor altsetting;
+
+ /* Using the base device, attempt to find the child with the
+ * matching bInterfaceProtocol */
+ dev = devinfo->dev;
+ for (i = 0; i < dev->num_children; i++) {
+ child = dev->children[i];
+ for (j = 0; j < child->descriptor.bNumConfigurations; j++) {
+ config = child->config[j];
+ for (k = 0; k < config.bNumInterfaces; k++) {
+ interface = config.interface[k];
+ for (l = 0; l < interface.num_altsetting; l++) {
+ altsetting = interface.altsetting[l];
+ if (altsetting.bInterfaceProtocol == bInterfaceProtocol) {
+ devinfo->dev = child;
+ return 1;
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
+
static void usage(char* error)
{
if (error)
@@ -289,6 +319,7 @@
"\t-v, --vendor= Vendor ID to act upon\n"
"\t-p, --product= Product ID to act upon\n"
"\t-m, --method= Method to use to switch [csr, logitech, dell]\n"
+ "\t-s, --resuscitate= Find the child device with this bInterfaceProtocol to run on \n"
"\n");
if (error)
exit(1);
@@ -301,6 +332,7 @@
{ "vendor", required_argument, 0, 'v' },
{ "product", required_argument, 0, 'p' },
{ "method", required_argument, 0, 'm' },
+ { "resuscitate",required_argument, 0, 's' },
{ 0, 0, 0, 0 }
};
@@ -309,8 +341,9 @@
struct device_info dev = { NULL, HCI, 0, 0 };
int opt, quiet = 0;
int (*method)(struct device_info *dev) = NULL;
+ uint8_t resuscitate = 0;
- while ((opt = getopt_long(argc, argv, "+r:v:p:m:qh", main_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, NULL)) != -1) {
switch (opt) {
case 'r':
if (optarg && !strcmp(optarg, "hid"))
@@ -339,6 +372,9 @@
case 'q':
quiet = 1;
break;
+ case 's':
+ sscanf(optarg, "%2hx", (short unsigned int*) &resuscitate);
+ break;
case 'h':
usage(NULL);
default:
@@ -362,6 +398,13 @@
exit(1);
}
+ if (resuscitate && !find_resuscitated_device(&dev, resuscitate)) {
+ if (!quiet)
+ fprintf(stderr, "Device %04x:%04x was unable to resucitate any child devices.\n",
+ dev.vendor,dev.product);
+ exit(1);
+ }
+
if (!quiet)
printf("Attempting to switch device %04x:%04x to %s mode ",
dev.vendor, dev.product, dev.mode ? "HID" : "HCI");
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next reply other threads:[~2009-07-16 21:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-16 21:37 Mario Limonciello [this message]
2009-07-24 16:27 ` [PATCH 1/2] Add support to hid2hci for recovering Dell BT devices Kay Sievers
2009-07-27 21:19 ` Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A5F9DA8.9020508@dell.com \
--to=mario_limonciello@dell.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.