diff --git a/sys/dev/hid/hidraw.c b/sys/dev/hid/hidraw.c index 8964e31f7bb..b558735ae1a 100644 --- a/sys/dev/hid/hidraw.c +++ b/sys/dev/hid/hidraw.c @@ -566,9 +566,10 @@ hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, #endif void *buf; struct hidraw_softc *sc; + struct hidraw_device_info *hdi; struct hidraw_gen_descriptor *hgd; struct hidraw_report_descriptor *hrd; - struct hidraw_devinfo *hdi; + struct hidraw_devinfo *hd; const char *devname; uint32_t size; int id, len; @@ -789,6 +790,23 @@ hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, *(int *)addr = 0; /* XXX: we only support reportid 0? */ return (0); + case HIDRAW_GET_DEVICEINFO: + hdi = (struct hidraw_device_info *)addr; + bzero(hdi, sizeof(struct hidraw_device_info)); + hdi->hdi_productNo = sc->sc_hw->idProduct; + hdi->hdi_vendorNo = sc->sc_hw->idVendor; + hdi->hdi_releaseNo = sc->sc_hw->idVersion; + hdi->hdi_busNo = sc->sc_hw->idBus; + strlcpy(hdi->hdi_name, sc->sc_hw->name, + sizeof(hdi->hdi_name)); + strlcpy(hdi->hdi_phys, device_get_nameunit(sc->sc_dev), + sizeof(hdi->hdi_phys)); + strlcpy(hdi->hdi_serial, sc->sc_hw->serial, + sizeof(hdi->hdi_serial)); + snprintf(hdi->hdi_release, sizeof(hdi->hdi_release), "%x.%02x", + sc->sc_hw->idVersion >> 8, sc->sc_hw->idVersion & 0xff); + return(0); + case HIDIOCGRDESCSIZE: *(int *)addr = sc->sc_hw->rdescsize; return (0); @@ -814,10 +832,10 @@ hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, return (error); case HIDIOCGRAWINFO: - hdi = (struct hidraw_devinfo *)addr; - hdi->bustype = sc->sc_hw->idBus; - hdi->vendor = sc->sc_hw->idVendor; - hdi->product = sc->sc_hw->idProduct; + hd = (struct hidraw_devinfo *)addr; + hd->bustype = sc->sc_hw->idBus; + hd->vendor = sc->sc_hw->idVendor; + hd->product = sc->sc_hw->idProduct; return (0); } diff --git a/sys/dev/hid/hidraw.h b/sys/dev/hid/hidraw.h index b1b037ab8c1..7f85cd536d2 100644 --- a/sys/dev/hid/hidraw.h +++ b/sys/dev/hid/hidraw.h @@ -51,6 +51,19 @@ struct hidraw_gen_descriptor { uint8_t reserved[8]; }; +/* Compatible with usb_device_info structure */ +struct hidraw_device_info { + uint16_t hdi_productNo; + uint16_t hdi_vendorNo; + uint16_t hdi_releaseNo; + uint16_t hdi_busNo; + char reserved[32]; + char hdi_name[128]; + char hdi_phys[128]; + char hdi_serial[64]; + char hdi_release[8]; +}; + struct hidraw_report_descriptor { uint32_t size; uint8_t value[HID_MAX_DESCRIPTOR_SIZE]; @@ -69,6 +82,7 @@ struct hidraw_devinfo { #define HIDRAW_SET_REPORT _IOW ('U', 24, struct hidraw_gen_descriptor) #define HIDRAW_GET_REPORT_ID _IOR ('U', 25, int) #define HIDRAW_SET_REPORT_DESC _IOW ('U', 26, struct hidraw_gen_descriptor) +#define HIDRAW_GET_DEVICEINFO _IOR ('U', 112, struct hidraw_device_info) /* Linux hidraw-compatible ioctl interface */ #define HIDIOCGRDESCSIZE _IOR('U', 30, int)