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 | 521 | s->dev.handle_data = usb_mouse_handle_data; |
522 | 522 | s->kind = USB_TABLET; |
523 | 523 | |
524 | + pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Tablet"); | |
525 | + | |
524 | 526 | return (USBDevice *)s; |
525 | 527 | } |
526 | 528 | |
... | ... | @@ -539,5 +541,7 @@ USBDevice *usb_mouse_init(void) |
539 | 541 | s->dev.handle_data = usb_mouse_handle_data; |
540 | 542 | s->kind = USB_MOUSE; |
541 | 543 | |
544 | + pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Mouse"); | |
545 | + | |
542 | 546 | return (USBDevice *)s; |
543 | 547 | } | ... | ... |
hw/usb-hub.c
... | ... | @@ -544,6 +544,8 @@ USBDevice *usb_hub_init(int nb_ports) |
544 | 544 | s->dev.handle_control = usb_hub_handle_control; |
545 | 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 | 549 | s->nb_ports = nb_ports; |
548 | 550 | for(i = 0; i < s->nb_ports; i++) { |
549 | 551 | port = &s->ports[i]; | ... | ... |
hw/usb-msd.c
... | ... | @@ -389,6 +389,9 @@ USBDevice *usb_msd_init(const char *filename) |
389 | 389 | s->dev.handle_control = usb_msd_handle_control; |
390 | 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 | 395 | s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s); |
393 | 396 | usb_msd_handle_reset((USBDevice *)s, 0); |
394 | 397 | return (USBDevice *)s; | ... | ... |
hw/usb.h
usb-linux.c
... | ... | @@ -44,11 +44,13 @@ typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id, |
44 | 44 | int vendor_id, int product_id, |
45 | 45 | const char *product_name, int speed); |
46 | 46 | static int usb_host_find_device(int *pbus_num, int *paddr, |
47 | + char *product_name, int product_name_size, | |
47 | 48 | const char *devname); |
48 | 49 | |
49 | 50 | //#define DEBUG |
50 | 51 | |
51 | 52 | #define USBDEVFS_PATH "/proc/bus/usb" |
53 | +#define PRODUCT_NAME_SZ 32 | |
52 | 54 | |
53 | 55 | typedef struct USBHostDevice { |
54 | 56 | USBDevice dev; |
... | ... | @@ -145,8 +147,11 @@ USBDevice *usb_host_device_open(const char *devname) |
145 | 147 | char buf[1024]; |
146 | 148 | int descr_len, dev_descr_len, config_descr_len, nb_interfaces; |
147 | 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 | 155 | return NULL; |
151 | 156 | |
152 | 157 | snprintf(buf, sizeof(buf), USBDEVFS_PATH "/%03d/%03d", |
... | ... | @@ -230,6 +235,14 @@ USBDevice *usb_host_device_open(const char *devname) |
230 | 235 | dev->dev.handle_reset = usb_host_handle_reset; |
231 | 236 | dev->dev.handle_control = usb_host_handle_control; |
232 | 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 | 246 | return (USBDevice *)dev; |
234 | 247 | } |
235 | 248 | |
... | ... | @@ -337,6 +350,7 @@ typedef struct FindDeviceState { |
337 | 350 | int product_id; |
338 | 351 | int bus_num; |
339 | 352 | int addr; |
353 | + char product_name[PRODUCT_NAME_SZ]; | |
340 | 354 | } FindDeviceState; |
341 | 355 | |
342 | 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 | 359 | const char *product_name, int speed) |
346 | 360 | { |
347 | 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 | 367 | s->bus_num = bus_num; |
351 | 368 | s->addr = addr; |
352 | 369 | return 1; |
... | ... | @@ -359,6 +376,7 @@ static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, |
359 | 376 | 'bus.addr' (decimal numbers) or |
360 | 377 | 'vendor_id:product_id' (hexa numbers) */ |
361 | 378 | static int usb_host_find_device(int *pbus_num, int *paddr, |
379 | + char *product_name, int product_name_size, | |
362 | 380 | const char *devname) |
363 | 381 | { |
364 | 382 | const char *p; |
... | ... | @@ -369,6 +387,11 @@ static int usb_host_find_device(int *pbus_num, int *paddr, |
369 | 387 | if (p) { |
370 | 388 | *pbus_num = strtoul(devname, NULL, 0); |
371 | 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 | 395 | return 0; |
373 | 396 | } |
374 | 397 | p = strchr(devname, ':'); |
... | ... | @@ -379,6 +402,7 @@ static int usb_host_find_device(int *pbus_num, int *paddr, |
379 | 402 | if (ret) { |
380 | 403 | *pbus_num = fs.bus_num; |
381 | 404 | *paddr = fs.addr; |
405 | + pstrcpy(product_name, product_name_size, fs.product_name); | |
382 | 406 | return 0; |
383 | 407 | } |
384 | 408 | } | ... | ... |
vl.c
... | ... | @@ -3785,8 +3785,8 @@ void usb_info(void) |
3785 | 3785 | speed_str = "?"; |
3786 | 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 | ... | ... |