qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Lonnie Mendez <lmendez19@austin.rr.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Large USB patch
Date: Fri, 21 Apr 2006 15:50:30 -0500	[thread overview]
Message-ID: <44494596.3070808@austin.rr.com> (raw)
In-Reply-To: <444926AC.3070104@austin.rr.com>

[-- Attachment #1: Type: text/plain, Size: 457 bytes --]

   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.

[-- Attachment #2: lusb-upd1.diff --]
[-- Type: text/plain, Size: 6133 bytes --]

--- 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");
 }

  reply	other threads:[~2006-04-21 20:50 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-20 19:59 [Qemu-devel] Large USB patch nix.wie.weg
2006-04-21  2:23 ` Lonnie Mendez
2006-04-21  5:59   ` nix.wie.weg
2006-04-21  7:04     ` Lonnie Mendez
2006-04-21 14:53 ` Lonnie Mendez
2006-04-21 15:00   ` Lonnie Mendez
2006-04-21 15:50   ` Lonnie Mendez
2006-04-21 16:19     ` Lonnie Mendez
2006-04-21 16:29       ` nix.wie.weg
2006-04-21 17:28         ` Lonnie Mendez
2006-04-21 18:06           ` Lonnie Mendez
2006-04-21 18:38             ` Lonnie Mendez
2006-04-21 20:50               ` Lonnie Mendez [this message]
2006-04-22  9:33                 ` nix.wie.weg
2006-04-22 14:36                   ` Lonnie Mendez
2006-04-22 15:36                     ` nix.wie.weg
2006-04-22 15:38                       ` nix.wie.weg
2006-04-22 16:00                     ` nix.wie.weg
2006-04-22 16:19                       ` Lonnie Mendez
2006-04-22 16:35                         ` nix.wie.weg
2006-04-23  3:38                           ` Lonnie Mendez
2006-04-23 21:54                             ` nix.wie.weg
2006-04-29  1:03                             ` Lonnie Mendez
2006-04-29  3:29                               ` Lonnie Mendez
2006-04-30  0:46                                 ` Lonnie Mendez
2006-04-30 20:56                                   ` Lonnie Mendez
2006-04-21 16:26     ` nix.wie.weg
2006-04-22 14:15 ` nix.wie.weg
2006-04-23 15:02 ` Fabrice Bellard
2006-04-23 16:11   ` nix.wie.weg
2006-04-24 23:50 ` [Qemu-devel] Update for cvs 2006-04-24 nix.wie.weg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44494596.3070808@austin.rr.com \
    --to=lmendez19@austin.rr.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).