From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Limonciello Date: Thu, 16 Jul 2009 21:37:44 +0000 Subject: [PATCH 1/2] Add support to hid2hci for recovering Dell BT devices Message-Id: <4A5F9DA8.9020508@dell.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------enigBF6FFDF63A6D5F4E8430B18E" List-Id: To: linux-hotplug@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBF6FFDF63A6D5F4E8430B18E Content-Type: multipart/mixed; boundary="------------060502050204070602030908" This is a multi-part message in MIME format. --------------060502050204070602030908 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi: Attached is the first of two follow up patches to the original thread titled "Explicitly disable BT radio using rfkill interface on suspend".=20 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 --=20 Mario Limonciello *Dell | Linux Engineering* mario_limonciello@dell.com --------------060502050204070602030908 Content-Type: text/x-patch; name="resuscitate.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="resuscitate.patch" =3D=3D=3D 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}=3D=3D"03", ATTR{bInterfaceSubClass}=3D=3D"01", ATT= R{bInterfaceProtocol}=3D=3D"02", ATTRS{bDeviceClass}=3D=3D"00", ATTRS{idV= endor}=3D=3D"413c", ATTRS{bmAttributes}=3D=3D"e0", \ RUN+=3D"hid2hci --method dell -v $attr{idVendor} -p $attr{idProduct}= --mode hci" =20 +# When a Dell device recovers from S3, the mouse child needs to be repok= ed +# Unfortunately the only event seen is the BT device disappearing, so th= e mouse +# device needs to be chased down on the USB bus. +ATTR{bDeviceClass}=3D=3D"e0", ATTR{bDeviceSubClass}=3D=3D"01", ATTR{bDev= iceProtocol}=3D=3D"01", ATTR{idVendor}=3D=3D"413c", ATTR{bmAttributes}=3D= =3D"e0", IMPORT{parent}=3D"ID_*", ENV{REMOVE_CMD}=3D"hid2hci --method del= l -v $env{ID_VENDOR_ID} -p $env{ID_MODEL_ID} --mode hci -s 02" + ENV{DEVTYPE}!=3D"usb_device", GOTO=3D"hid2hci_end" =20 # Logitech devices =3D=3D=3D 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; } =20 +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 =3D devinfo->dev; + for (i =3D 0; i < dev->num_children; i++) { + child =3D dev->children[i]; + for (j =3D 0; j < child->descriptor.bNumConfigurations; j++) { + config =3D child->config[j]; + for (k =3D 0; k < config.bNumInterfaces; k++) { + interface =3D config.interface[k]; + for (l =3D 0; l < interface.num_altsetting; l++) { + altsetting =3D interface.altsetting[l]; + if (altsetting.bInterfaceProtocol =3D=3D bInterfaceProtocol) { + devinfo->dev =3D child; + return 1; + } + } + } + } + } + return 0; +} + static void usage(char* error) { if (error) @@ -289,6 +319,7 @@ "\t-v, --vendor=3D Vendor ID to act upon\n" "\t-p, --product=3D Product ID to act upon\n" "\t-m, --method=3D Method to use to switch [csr, logitech, dell= ]\n" + "\t-s, --resuscitate=3D Find the child device with this bInterfacePr= otocol 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 } }; =20 @@ -309,8 +341,9 @@ struct device_info dev =3D { NULL, HCI, 0, 0 }; int opt, quiet =3D 0; int (*method)(struct device_info *dev) =3D NULL; + uint8_t resuscitate =3D 0; =20 - while ((opt =3D getopt_long(argc, argv, "+r:v:p:m:qh", main_options, NU= LL)) !=3D -1) { + while ((opt =3D getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, = NULL)) !=3D -1) { switch (opt) { case 'r': if (optarg && !strcmp(optarg, "hid")) @@ -339,6 +372,9 @@ case 'q': quiet =3D 1; break; + case 's': + sscanf(optarg, "%2hx", (short unsigned int*) &resuscitate); + break; case 'h': usage(NULL); default: @@ -362,6 +398,13 @@ exit(1); } =20 + 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"); --------------060502050204070602030908-- --------------enigBF6FFDF63A6D5F4E8430B18E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpfnagACgkQ2CrZjkA73YtVQQCZAVfsf/9SQcE0QZYnfl9WcXta bbIAnRji0/OoOXgd0bQLoSQOiHHbbf1o =b6pq -----END PGP SIGNATURE----- --------------enigBF6FFDF63A6D5F4E8430B18E--