USBHID之内核抢占USB驱动问题

本文基于mstar801平台Linux2.6.35.11内核版本。

  前些天调试一个elan的USB触摸板,发现插上USB dongle后、加载的驱动总是不对。

  后经同事分析,是加载了错误的驱动导致;USB发现机制里边根据设备VID和PID匹配了USBHID设备。

  因此,要解决这个问题需要在USBHID忽略列表里边添加自己elan USB触摸板的VID和PID;具体做法如下:

1.获得本设备VID和PID

  通过插入USB dongle后看串口输出的VID和PID;

  或在驱动代码中查找:

kernel2.6.35.11/drivers/input/elan_tp/elan_tp.c

#define VENDOR_ID			0x1D5A
#define PRODUCT_ID		0xC0B3	

#define VENDOR_ID_1		0x201e
#define PRODUCT_ID_1		0x003c

#define VENDOR_ID_2		0x04f3
#define PRODUCT_ID_2		0x0726

2.在USBHID设备忽略列表中加上这些VID和PID

  kernel2.6.35.11/driver/hid/usbhid/hid-core.c

static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id)
{       ......
	dbg_hid("HID probe called for ifnum %d\n",
			intf->altsetting->desc.bInterfaceNumber);
        //add by tank
	if ((dev->descriptor.idVendor == 0x1D5A)&&(dev->descriptor.idProduct == 0xC0B3)) {
			return -ENODEV ;
	}
        if ((dev->descriptor.idVendor == 0x201e)&&(dev->descriptor.idProduct == 0x003c)) {
			return -ENODEV ;
	}
	if ((dev->descriptor.idVendor == 0x04f3)&&(dev->descriptor.idProduct == 0726)) {
			return -ENODEV ;
	}
	printk("hid-core.c idVendor = %x , idProduct=%x\n",dev->descriptor.idVendor,dev->descriptor.idProduct);
	printk("hid-core.c interface->desc.bInterfaceNumber:%d desc.bNumEndpoints:%d\n",interface->desc.bInterfaceNumber,interface->desc.bNumEndpoints);
        //end by tank
	for (n = 0; n < interface->desc.bNumEndpoints; n++)
		if (usb_endpoint_is_int_in(&interface->endpoint[n].desc))
			has_in++;
        ......
}

  或kernel2.6.35.11/driver/hid/hid-core.c

static const struct hid_device_id hid_ignore_list[] = {
  .....
  //add by tank
        { HID_USB_DEVICE(0x1D5A, 0xC0B3) },
        { HID_USB_DEVICE(0x201e, 0x003c) },
        { HID_USB_DEVICE(0x04f3, 0x0726) },
  //end by tank
        { }
}

3.补充-HID设备支持情况

  kernel2.6.35.11/drivers/hid/hid-id.h

你可能感兴趣的:(USBHID之内核抢占USB驱动问题)