usb鼠标驱动注解及测试

[11-20 15:53:39]   来源:http://www.88dzw.com  arm嵌入式   阅读:8872

文章摘要:.match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \.bInterfaceClass = (cl), \.bInterfaceSubClass = (sc), \.bInterfaceProtocol = (pr)鼠标设备遵循USB人机接口设备(HID),在HID规范中规定鼠标接口类码为:接口类:0x03接口子类:0x01接口协议:0x02这样分类的好处是设备厂商可以直接利用标准的驱动程序。除了HID类以外还有Mass storage、printer、audio等#define USB_DEVICE_ID_MATCH_INT_INFO \(USB_DEV

usb鼠标驱动注解及测试,标签:arm嵌入式系统,arm系统,http://www.88dzw.com

  .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \

  .bInterfaceClass = (cl), \

  .bInterfaceSubClass = (sc), \

  .bInterfaceProtocol = (pr)

  鼠标设备遵循USB人机接口设备(HID),在HID规范中规定鼠标接口类码为:

  接口类:0x03

  接口子类:0x01

  接口协议:0x02

  这样分类的好处是设备厂商可以直接利用标准的驱动程序。除了HID类以外还有Mass storage、printer、audio等

  #define USB_DEVICE_ID_MATCH_INT_INFO \

  (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)

  匹配的过程为:

  usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)

  {

  struct usb_host_interface *intf;

  struct usb_device *dev;

  /* proc_connectinfo in devio.c may call us with id == NULL. */

  if (id == NULL)

  return NULL;

  intf = interface->cur_altsetting;

  dev = interface_to_usbdev(interface);

  /* It is important to check that id->driver_info is nonzero,

  since an entry that is all zeroes except for a nonzero

  id->driver_info is the way to create an entry that

  indicates that the driver want to examine every

  device and interface. */

  for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass ||

  id->driver_info; id++) {

  if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&

  id->idVendor != le16_to_cpu(dev->descriptor.idVendor))

  continue;

  if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&

  id->idProduct != le16_to_cpu(dev->descriptor.idProduct))

  continue;

  /* No need to test id->bcdDevice_lo != 0, since 0 is never greater than any unsigned number. */

  if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&

  (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))

  continue;

  if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&

  (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))

  continue;

  if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&

  (id->bDeviceClass != dev->descriptor.bDeviceClass))

  continue;

  if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&

  (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass))

  continue;

  if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&

  (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))

  continue;

  //接口类

  if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&

  (id->bInterfaceClass != intf->desc.bInterfaceClass))

  continue;

  //接口子类

  if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&

  (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))

  continue;

  //遵循的协议

  if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&

  (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))

  continue;

  return id;

  }

  return NULL;

  }

  从中可以看出,只有当设备的接口类、接口子类、接口协议匹配鼠标驱动时鼠标驱动才会调用probe方法。

  二、probe部分

上一页  [1] [2] [3] [4] [5] [6] [7]  下一页


Tag:arm嵌入式arm嵌入式系统,arm系统arm嵌入式

《usb鼠标驱动注解及测试》相关文章

分类导航
最新更新
热门排行