=== modified file 'extras/hid2hci/70-hid2hci.rules' --- extras/hid2hci/70-hid2hci.rules 2009-07-16 17:27:14 +0000 +++ extras/hid2hci/70-hid2hci.rules 2009-07-16 20:38:08 +0000 @@ -9,22 +9,22 @@ # # Known supported devices: 413c:8154, 413c:8158, 413c:8162 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" + RUN+="hid2hci --method dell -b $attr{busnum} -d $attr{devnum} --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" +ATTR{bDeviceClass}=="e0", ATTR{bDeviceSubClass}=="01", ATTR{bDeviceProtocol}=="01", ATTR{idVendor}=="413c", ATTR{bmAttributes}=="e0", IMPORT{parent}="DEVNUM", ENV{REMOVE_CMD}="hid2hci --method dell -b $attr{busnum} -d $env{DEVNUM} --mode hci -s 02" ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end" # Logitech devices -ATTR{idVendor}=="046d", ATTR{idProduct}=="c70[345abce]", RUN+="hid2hci --method logitech -v $attr{idVendor} -p $attr{idProduct} --mode hci" -ATTR{idVendor}=="046d", ATTR{idProduct}=="c71[34bc]", RUN+="hid2hci --method logitech -v $attr{idVendor} -p $attr{idProduct} --mode hci" +ATTR{idVendor}=="046d", ATTR{idProduct}=="c70[345abce]", RUN+="hid2hci --method logitech -b $attr{busnum} -d $attr{devnum} --mode hci" +ATTR{idVendor}=="046d", ATTR{idProduct}=="c71[34bc]", RUN+="hid2hci --method logitech -b $attr{busnum} -d $attr{devnum} --mode hci" # CSR devices (in HID mode) -ATTR{idVendor}=="0a12", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci" -ATTR{idVendor}=="0458", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci" -ATTR{idVendor}=="05ac", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci" +ATTR{idVendor}=="0a12", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -b $attr{busnum} -d $attr{devnum} --mode hci" +ATTR{idVendor}=="0458", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -b $attr{busnum} -d $attr{devnum} --mode hci" +ATTR{idVendor}=="05ac", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -b $attr{busnum} -d $attr{devnum} --mode hci" LABEL="hid2hci_end" === modified file 'extras/hid2hci/hid2hci.c' --- extras/hid2hci/hid2hci.c 2009-07-16 17:27:14 +0000 +++ extras/hid2hci/hid2hci.c 2009-07-16 20:38:10 +0000 @@ -90,8 +90,8 @@ struct device_info { struct usb_device *dev; int mode; - uint16_t vendor; - uint16_t product; + int devnum; + int dirname; }; static int switch_csr(struct device_info *devinfo) @@ -261,13 +261,12 @@ usb_find_devices(); for (bus = usb_get_busses(); bus; bus = bus->next) - for (dev = bus->devices; dev; dev = dev->next) { - if (dev->descriptor.idVendor == devinfo->vendor && - dev->descriptor.idProduct == devinfo->product) { - devinfo->dev=dev; - return 1; - } - } + if (strtol(bus->dirname, NULL, 10) == devinfo->dirname) + for (dev = bus->devices; dev; dev = dev->next) + if (dev->devnum == devinfo->devnum) { + devinfo->dev=dev; + return 1; + } return 0; } @@ -316,8 +315,8 @@ "\t-h, --help Display help\n" "\t-q, --quiet Don't display any messages\n" "\t-r, --mode= Mode to switch to [hid, hci]\n" - "\t-v, --vendor= Vendor ID to act upon\n" - "\t-p, --product= Product ID to act upon\n" + "\t-b, --busnum= USB Bus number to operate on\n" + "\t-d, --devnum= USB Device number to operate on\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"); @@ -329,8 +328,8 @@ { "help", no_argument, 0, 'h' }, { "quiet", no_argument, 0, 'q' }, { "mode", required_argument, 0, 'r' }, - { "vendor", required_argument, 0, 'v' }, - { "product", required_argument, 0, 'p' }, + { "busnum", required_argument, 0, 'b' }, + { "devnum", required_argument, 0, 'd' }, { "method", required_argument, 0, 'm' }, { "resuscitate",required_argument, 0, 's' }, { 0, 0, 0, 0 } @@ -343,7 +342,7 @@ int (*method)(struct device_info *dev) = NULL; uint8_t resuscitate = 0; - while ((opt = getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "+s:r:b:d:m:qh", main_options, NULL)) != -1) { switch (opt) { case 'r': if (optarg && !strcmp(optarg, "hid")) @@ -353,11 +352,11 @@ else usage("ERROR: Undefined radio mode\n"); break; - case 'v': - sscanf(optarg, "%4hx", &dev.vendor); + case 'd': + sscanf(optarg, "%d", &dev.devnum); break; - case 'p': - sscanf(optarg, "%4hx", &dev.product); + case 'b': + sscanf(optarg, "%d", &dev.dirname); break; case 'm': if (optarg && !strcmp(optarg, "csr")) @@ -382,8 +381,8 @@ } } - if (!quiet && (!dev.vendor || !dev.product || !method)) - usage("ERROR: Vendor ID, Product ID, and Switching Method must all be defined.\n"); + if (!quiet && (!dev.dirname || !dev.devnum || !method)) + usage("ERROR: USB Bus number, USB Device number, and Switching Method must all be defined.\n"); argc -= optind; argv += optind; @@ -393,21 +392,21 @@ if (!find_device(&dev)) { if (!quiet) - fprintf(stderr, "Device %04x:%04x not found on USB bus.\n", - dev.vendor, dev.product); + fprintf(stderr, "Bus %03d Device %03d not found.\n", + dev.dirname, dev.devnum); 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); + fprintf(stderr, "Bus %03d Device %03d was unable to resucitate any child devices.\n", + dev.dirname,dev.devnum); exit(1); } if (!quiet) - printf("Attempting to switch device %04x:%04x to %s mode ", - dev.vendor, dev.product, dev.mode ? "HID" : "HCI"); + printf("Attempting to switch device Bus %03d Device %03d to %s mode ", + dev.dirname, dev.devnum, dev.mode ? "HID" : "HCI"); fflush(stdout); if (method(&dev) < 0 && !quiet)