Commit 1f6e24e73ccdca64864da009a21f5b7051d200a1
1 parent
3e382bc8
display device identifier string for user with info usb (Lonnie Mendez)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2029 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
6 changed files
with
39 additions
and
5 deletions
hw/usb-hid.c
| @@ -521,6 +521,8 @@ USBDevice *usb_tablet_init(void) | @@ -521,6 +521,8 @@ USBDevice *usb_tablet_init(void) | ||
| 521 | s->dev.handle_data = usb_mouse_handle_data; | 521 | s->dev.handle_data = usb_mouse_handle_data; |
| 522 | s->kind = USB_TABLET; | 522 | s->kind = USB_TABLET; |
| 523 | 523 | ||
| 524 | + pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Tablet"); | ||
| 525 | + | ||
| 524 | return (USBDevice *)s; | 526 | return (USBDevice *)s; |
| 525 | } | 527 | } |
| 526 | 528 | ||
| @@ -539,5 +541,7 @@ USBDevice *usb_mouse_init(void) | @@ -539,5 +541,7 @@ USBDevice *usb_mouse_init(void) | ||
| 539 | s->dev.handle_data = usb_mouse_handle_data; | 541 | s->dev.handle_data = usb_mouse_handle_data; |
| 540 | s->kind = USB_MOUSE; | 542 | s->kind = USB_MOUSE; |
| 541 | 543 | ||
| 544 | + pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Mouse"); | ||
| 545 | + | ||
| 542 | return (USBDevice *)s; | 546 | return (USBDevice *)s; |
| 543 | } | 547 | } |
hw/usb-hub.c
| @@ -544,6 +544,8 @@ USBDevice *usb_hub_init(int nb_ports) | @@ -544,6 +544,8 @@ USBDevice *usb_hub_init(int nb_ports) | ||
| 544 | s->dev.handle_control = usb_hub_handle_control; | 544 | s->dev.handle_control = usb_hub_handle_control; |
| 545 | s->dev.handle_data = usb_hub_handle_data; | 545 | s->dev.handle_data = usb_hub_handle_data; |
| 546 | 546 | ||
| 547 | + pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Hub"); | ||
| 548 | + | ||
| 547 | s->nb_ports = nb_ports; | 549 | s->nb_ports = nb_ports; |
| 548 | for(i = 0; i < s->nb_ports; i++) { | 550 | for(i = 0; i < s->nb_ports; i++) { |
| 549 | port = &s->ports[i]; | 551 | port = &s->ports[i]; |
hw/usb-msd.c
| @@ -389,6 +389,9 @@ USBDevice *usb_msd_init(const char *filename) | @@ -389,6 +389,9 @@ USBDevice *usb_msd_init(const char *filename) | ||
| 389 | s->dev.handle_control = usb_msd_handle_control; | 389 | s->dev.handle_control = usb_msd_handle_control; |
| 390 | s->dev.handle_data = usb_msd_handle_data; | 390 | s->dev.handle_data = usb_msd_handle_data; |
| 391 | 391 | ||
| 392 | + snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)", | ||
| 393 | + filename); | ||
| 394 | + | ||
| 392 | s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s); | 395 | s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s); |
| 393 | usb_msd_handle_reset((USBDevice *)s, 0); | 396 | usb_msd_handle_reset((USBDevice *)s, 0); |
| 394 | return (USBDevice *)s; | 397 | return (USBDevice *)s; |
hw/usb.h
| @@ -128,6 +128,7 @@ struct USBDevice { | @@ -128,6 +128,7 @@ struct USBDevice { | ||
| 128 | int (*handle_data)(USBDevice *dev, int pid, uint8_t devep, | 128 | int (*handle_data)(USBDevice *dev, int pid, uint8_t devep, |
| 129 | uint8_t *data, int len); | 129 | uint8_t *data, int len); |
| 130 | uint8_t addr; | 130 | uint8_t addr; |
| 131 | + char devname[32]; | ||
| 131 | 132 | ||
| 132 | int state; | 133 | int state; |
| 133 | uint8_t setup_buf[8]; | 134 | uint8_t setup_buf[8]; |
usb-linux.c
| @@ -44,11 +44,13 @@ typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id, | @@ -44,11 +44,13 @@ typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id, | ||
| 44 | int vendor_id, int product_id, | 44 | int vendor_id, int product_id, |
| 45 | const char *product_name, int speed); | 45 | const char *product_name, int speed); |
| 46 | static int usb_host_find_device(int *pbus_num, int *paddr, | 46 | static int usb_host_find_device(int *pbus_num, int *paddr, |
| 47 | + char *product_name, int product_name_size, | ||
| 47 | const char *devname); | 48 | const char *devname); |
| 48 | 49 | ||
| 49 | //#define DEBUG | 50 | //#define DEBUG |
| 50 | 51 | ||
| 51 | #define USBDEVFS_PATH "/proc/bus/usb" | 52 | #define USBDEVFS_PATH "/proc/bus/usb" |
| 53 | +#define PRODUCT_NAME_SZ 32 | ||
| 52 | 54 | ||
| 53 | typedef struct USBHostDevice { | 55 | typedef struct USBHostDevice { |
| 54 | USBDevice dev; | 56 | USBDevice dev; |
| @@ -145,8 +147,11 @@ USBDevice *usb_host_device_open(const char *devname) | @@ -145,8 +147,11 @@ USBDevice *usb_host_device_open(const char *devname) | ||
| 145 | char buf[1024]; | 147 | char buf[1024]; |
| 146 | int descr_len, dev_descr_len, config_descr_len, nb_interfaces; | 148 | int descr_len, dev_descr_len, config_descr_len, nb_interfaces; |
| 147 | int bus_num, addr; | 149 | int bus_num, addr; |
| 150 | + char product_name[PRODUCT_NAME_SZ]; | ||
| 148 | 151 | ||
| 149 | - if (usb_host_find_device(&bus_num, &addr, devname) < 0) | 152 | + if (usb_host_find_device(&bus_num, &addr, |
| 153 | + product_name, sizeof(product_name), | ||
| 154 | + devname) < 0) | ||
| 150 | return NULL; | 155 | return NULL; |
| 151 | 156 | ||
| 152 | snprintf(buf, sizeof(buf), USBDEVFS_PATH "/%03d/%03d", | 157 | snprintf(buf, sizeof(buf), USBDEVFS_PATH "/%03d/%03d", |
| @@ -230,6 +235,14 @@ USBDevice *usb_host_device_open(const char *devname) | @@ -230,6 +235,14 @@ USBDevice *usb_host_device_open(const char *devname) | ||
| 230 | dev->dev.handle_reset = usb_host_handle_reset; | 235 | dev->dev.handle_reset = usb_host_handle_reset; |
| 231 | dev->dev.handle_control = usb_host_handle_control; | 236 | dev->dev.handle_control = usb_host_handle_control; |
| 232 | dev->dev.handle_data = usb_host_handle_data; | 237 | dev->dev.handle_data = usb_host_handle_data; |
| 238 | + | ||
| 239 | + if (product_name[0] == '\0') | ||
| 240 | + snprintf(dev->dev.devname, sizeof(dev->dev.devname), | ||
| 241 | + "host:%s", devname); | ||
| 242 | + else | ||
| 243 | + pstrcpy(dev->dev.devname, sizeof(dev->dev.devname), | ||
| 244 | + product_name); | ||
| 245 | + | ||
| 233 | return (USBDevice *)dev; | 246 | return (USBDevice *)dev; |
| 234 | } | 247 | } |
| 235 | 248 | ||
| @@ -337,6 +350,7 @@ typedef struct FindDeviceState { | @@ -337,6 +350,7 @@ typedef struct FindDeviceState { | ||
| 337 | int product_id; | 350 | int product_id; |
| 338 | int bus_num; | 351 | int bus_num; |
| 339 | int addr; | 352 | int addr; |
| 353 | + char product_name[PRODUCT_NAME_SZ]; | ||
| 340 | } FindDeviceState; | 354 | } FindDeviceState; |
| 341 | 355 | ||
| 342 | static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, | 356 | static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, |
| @@ -345,8 +359,11 @@ static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, | @@ -345,8 +359,11 @@ static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, | ||
| 345 | const char *product_name, int speed) | 359 | const char *product_name, int speed) |
| 346 | { | 360 | { |
| 347 | FindDeviceState *s = opaque; | 361 | FindDeviceState *s = opaque; |
| 348 | - if (vendor_id == s->vendor_id && | ||
| 349 | - product_id == s->product_id) { | 362 | + if ((vendor_id == s->vendor_id && |
| 363 | + product_id == s->product_id) || | ||
| 364 | + (bus_num == s->bus_num && | ||
| 365 | + addr == s->addr)) { | ||
| 366 | + pstrcpy(s->product_name, PRODUCT_NAME_SZ, product_name); | ||
| 350 | s->bus_num = bus_num; | 367 | s->bus_num = bus_num; |
| 351 | s->addr = addr; | 368 | s->addr = addr; |
| 352 | return 1; | 369 | return 1; |
| @@ -359,6 +376,7 @@ static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, | @@ -359,6 +376,7 @@ static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, | ||
| 359 | 'bus.addr' (decimal numbers) or | 376 | 'bus.addr' (decimal numbers) or |
| 360 | 'vendor_id:product_id' (hexa numbers) */ | 377 | 'vendor_id:product_id' (hexa numbers) */ |
| 361 | static int usb_host_find_device(int *pbus_num, int *paddr, | 378 | static int usb_host_find_device(int *pbus_num, int *paddr, |
| 379 | + char *product_name, int product_name_size, | ||
| 362 | const char *devname) | 380 | const char *devname) |
| 363 | { | 381 | { |
| 364 | const char *p; | 382 | const char *p; |
| @@ -369,6 +387,11 @@ static int usb_host_find_device(int *pbus_num, int *paddr, | @@ -369,6 +387,11 @@ static int usb_host_find_device(int *pbus_num, int *paddr, | ||
| 369 | if (p) { | 387 | if (p) { |
| 370 | *pbus_num = strtoul(devname, NULL, 0); | 388 | *pbus_num = strtoul(devname, NULL, 0); |
| 371 | *paddr = strtoul(p + 1, NULL, 0); | 389 | *paddr = strtoul(p + 1, NULL, 0); |
| 390 | + fs.bus_num = *pbus_num; | ||
| 391 | + fs.addr = *paddr; | ||
| 392 | + ret = usb_host_scan(&fs, usb_host_find_device_scan); | ||
| 393 | + if (ret) | ||
| 394 | + pstrcpy(product_name, product_name_size, fs.product_name); | ||
| 372 | return 0; | 395 | return 0; |
| 373 | } | 396 | } |
| 374 | p = strchr(devname, ':'); | 397 | p = strchr(devname, ':'); |
| @@ -379,6 +402,7 @@ static int usb_host_find_device(int *pbus_num, int *paddr, | @@ -379,6 +402,7 @@ static int usb_host_find_device(int *pbus_num, int *paddr, | ||
| 379 | if (ret) { | 402 | if (ret) { |
| 380 | *pbus_num = fs.bus_num; | 403 | *pbus_num = fs.bus_num; |
| 381 | *paddr = fs.addr; | 404 | *paddr = fs.addr; |
| 405 | + pstrcpy(product_name, product_name_size, fs.product_name); | ||
| 382 | return 0; | 406 | return 0; |
| 383 | } | 407 | } |
| 384 | } | 408 | } |
vl.c
| @@ -3785,8 +3785,8 @@ void usb_info(void) | @@ -3785,8 +3785,8 @@ void usb_info(void) | ||
| 3785 | speed_str = "?"; | 3785 | speed_str = "?"; |
| 3786 | break; | 3786 | break; |
| 3787 | } | 3787 | } |
| 3788 | - term_printf(" Device %d.%d, speed %s Mb/s\n", | ||
| 3789 | - 0, dev->addr, speed_str); | 3788 | + term_printf(" Device %d.%d, Speed %s Mb/s, Product %s\n", |
| 3789 | + 0, dev->addr, speed_str, dev->devname); | ||
| 3790 | } | 3790 | } |
| 3791 | } | 3791 | } |
| 3792 | 3792 |