From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FX2aM-0002Nm-0k for qemu-devel@nongnu.org; Fri, 21 Apr 2006 16:50:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FX2aK-0002Mu-Lw for qemu-devel@nongnu.org; Fri, 21 Apr 2006 16:50:36 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FX2aK-0002Mr-Iz for qemu-devel@nongnu.org; Fri, 21 Apr 2006 16:50:36 -0400 Received: from [24.93.47.41] (helo=ms-smtp-02.texas.rr.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FX2bx-0002sa-9I for qemu-devel@nongnu.org; Fri, 21 Apr 2006 16:52:17 -0400 Received: from [192.168.0.11] (cpe-67-9-160-120.austin.res.rr.com [67.9.160.120]) by ms-smtp-02.texas.rr.com (8.13.4/8.13.4) with ESMTP id k3LKoWmw027810 for ; Fri, 21 Apr 2006 15:50:32 -0500 (CDT) Message-ID: <44494596.3070808@austin.rr.com> Date: Fri, 21 Apr 2006 15:50:30 -0500 From: Lonnie Mendez MIME-Version: 1.0 Subject: Re: [Qemu-devel] Large USB patch References: <4447E811.1040403@gmx.de> <4448F1F6.4090609@austin.rr.com> <4448FF3F.3030009@austin.rr.com> <44490614.50406@austin.rr.com> <44490852.2080608@gmx.de> <44491659.30804@austin.rr.com> <44491F0A.2090608@austin.rr.com> <444926AC.3070104@austin.rr.com> In-Reply-To: <444926AC.3070104@austin.rr.com> Content-Type: multipart/mixed; boundary="------------000803010705010305030705" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------000803010705010305030705 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Another patch. This one does a few things: -fixes minor output bugs and some various OBO bugs -adds some improvements to the emulated hub -sets up the emulated devices to use the generic message handler (they now work again) -makes tablet device visible to usb_add There are of course more bugs I've found. Namely being able to usb_add any particular string with that string showing up as a new device even though no valid entry for it exists. --------------000803010705010305030705 Content-Type: text/plain; name="lusb-upd1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="lusb-upd1.diff" --- a/qemu/hw/usb.c 2006-04-21 11:15:40.000000000 -0500 +++ b/qemu/hw/usb.c 2006-04-21 15:27:19.000000000 -0500 @@ -455,6 +455,10 @@ /* we found a guest usb mouse */ tree->dev= usb_mouse_init (); return add_usb_device (tree); + } else if (strcmp (tree->name,"tablet") == 0) { + /* we found a guest usb tablet */ + tree->dev = usb_tablet_init (); + return add_usb_device (tree); } return 1; } @@ -491,6 +495,7 @@ usb_host_info(); usb_hub_info(); usb_mouse_info(); + usb_tablet_info(); } void usb_print_childs (USBTree *tree, int layer) { --- a/qemu/hw/usb.h 2006-04-21 11:15:40.000000000 -0500 +++ b/qemu/hw/usb.h 2006-04-21 15:27:58.000000000 -0500 @@ -242,7 +242,9 @@ void usb_hub_info (void); /* usb-hid.c */ USBDevice* usb_mouse_init (void); +USBDevice* usb_tablet_init (void); void usb_mouse_info (void); +void usb_tablet_info (void); /* The usb dummy device functions, they exist only to make it easier to --- a/qemu/hw/usb-hub.c 2006-04-21 11:15:40.000000000 -0500 +++ b/qemu/hw/usb-hub.c 2006-04-21 15:23:05.000000000 -0500 @@ -165,9 +165,9 @@ 0x0a, /* u16 wHubCharacteristics; */ 0x00, /* (per-port OC, no power switching) */ 0x01, /* u8 bPwrOn2pwrGood; 2ms */ - 0x00, /* u8 bHubContrCurrent; 0 mA */ - 0x00, /* u8 DeviceRemovable; *** 7 Ports max *** */ - 0xff /* u8 PortPwrCtrlMask; *** 7 ports max *** */ + 0x00 /* u8 bHubContrCurrent; 0 mA */ + + /* DeviceRemovable and PortPwrCtrlMask patched in later */ }; static int usb_hub_attach (USBDevice *hub, USBDevice *dev, int portnum) @@ -260,6 +260,12 @@ } ret = 0; break; + case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: + if (value == 0 && index != 0x81) { /* clear ep halt */ + goto fail; + } + ret = 0; + break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 1; @@ -282,6 +288,11 @@ case USB_DT_CONFIG: memcpy(data, qemu_hub_config_descriptor, sizeof(qemu_hub_config_descriptor)); + + /* status change endpoint size based on number + * of ports */ + data[22] = (s->nb_ports + 1 + 7) / 8; + ret = sizeof(qemu_hub_config_descriptor); break; case USB_DT_STRING: @@ -427,11 +438,29 @@ } break; case GetHubDescriptor: - memcpy(data, qemu_hub_hub_descriptor, - sizeof(qemu_hub_hub_descriptor)); - data[2] = s->nb_ports; - ret = sizeof(qemu_hub_hub_descriptor); - break; + { + unsigned int n, limit, var_hub_size = 0; + memcpy(data, qemu_hub_hub_descriptor, + sizeof(qemu_hub_hub_descriptor)); + data[2] = s->nb_ports; + + /* fill DeviceRemovable bits */ + limit = ((s->nb_ports + 1 + 7) / 8) + 7; + for (n = 7; n < limit; n++) { + data[n] = 0x00; + var_hub_size++; + } + + /* fill PortPwrCtrlMask bits */ + limit = limit + ((s->nb_ports + 7) / 8); + for (;n < limit; n++) { + data[n] = 0xff; + var_hub_size++; + } + + ret = sizeof(qemu_hub_hub_descriptor) + var_hub_size; + break; + } default: fail: ret = USB_RET_STALL; @@ -453,8 +482,11 @@ unsigned int status; int i, n; n = (s->nb_ports + 1 + 7) / 8; - if (n > len) + if (len == 1) { /* FreeBSD uhub workaround */ + n = 1; + } else if (n > len) { return USB_RET_BABBLE; + } status = 0; for(i = 0; i < s->nb_ports; i++) { port = &s->ports[i]; @@ -467,7 +499,7 @@ } ret = n; } else { - ret = 0; + ret = USB_RET_NAK; /* usb_20 11.12.1 */ } } else { goto fail; @@ -541,6 +573,7 @@ return NULL; dev->opaque= s; dev->speed= USB_SPEED_FULL; + dev->handle_msg= usb_generic_handle_msg; dev->handle_packet= usb_hub_handle_packet; dev->handle_attach= usb_hub_attach; dev->handle_reset= usb_hub_handle_reset; @@ -558,5 +591,5 @@ void usb_hub_info(void) { term_printf(" Device usbhub, Manufacturer QEMU, Product QEMU USB Hub\n" ); - term_printf (" VendorID:ProductID 0000:0000, USB-Standard: 01.01\n"); + term_printf (" VendorID:ProductID 0000:0000, USB-Standard: 01.10\n"); } --- a/qemu/hw/usb-hid.c 2006-04-21 11:15:40.000000000 -0500 +++ b/qemu/hw/usb-hid.c 2006-04-21 15:31:55.000000000 -0500 @@ -515,6 +515,7 @@ return NULL; dev->opaque= s; dev->speed= USB_SPEED_FULL; + dev->handle_msg= usb_generic_handle_msg; dev->handle_packet= usb_generic_handle_packet; dev->handle_reset= usb_mouse_handle_reset; @@ -536,6 +539,7 @@ return NULL; dev->opaque= s; dev->speed= USB_SPEED_FULL; + dev->handle_msg= usb_generic_handle_msg; dev->handle_packet= usb_generic_handle_packet; dev->handle_reset= usb_mouse_handle_reset; @@ -549,5 +553,10 @@ void usb_mouse_info() { term_printf(" Device mouse, Manufacturer QEMU, Product QEMU USB Mouse\n" ); - term_printf (" VendorID:ProductID 2706:0001, USB-Standard: 01.00\n"); + term_printf (" VendorID:ProductID 0627:0001, USB-Standard: 01.00\n"); +} + +void usb_tablet_info() { + term_printf(" Device tablet, Manufacturer QEMU, Product QEMU USB Tablet\n"); + term_printf (" VendorID:ProductID 0627:0001, USB-Standard: 01.00\n"); } --------------000803010705010305030705--