Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HiBtB-0007MW-L9 for qemu-devel@nongnu.org; Sun, 29 Apr 2007 12:04:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HiBt8-0007LO-Mc for qemu-devel@nongnu.org; Sun, 29 Apr 2007 12:04:41 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HiBt8-0007LG-Hc for qemu-devel@nongnu.org; Sun, 29 Apr 2007 12:04:38 -0400 Received: from ryu.zarb.org ([212.85.153.228]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HiBn2-0003AV-Fb for qemu-devel@nongnu.org; Sun, 29 Apr 2007 11:58:20 -0400 Received: from localhost (localhost [127.0.0.1]) by ryu.zarb.org (Postfix) with ESMTP id DCD6667005A for ; Sun, 29 Apr 2007 17:58:13 +0200 (CEST) Received: from ryu.zarb.org ([127.0.0.1]) by localhost (ryu.zarb.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id ovP3mBwjrmuV for ; Sun, 29 Apr 2007 17:58:12 +0200 (CEST) Received: from localnet (unknown [85.2.58.141]) by ryu.zarb.org (Postfix) with ESMTP id B576967002F for ; Sun, 29 Apr 2007 17:58:12 +0200 (CEST) From: Couriousous Date: Sun, 29 Apr 2007 17:58:49 +0200 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_5CMNGcW9uZPM29y" Message-Id: <200704291758.49641.couriousous@sceen.net> Subject: [Qemu-devel] USB Multiple interface devices 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 --Boundary-00=_5CMNGcW9uZPM29y Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello Currently qemu doesn't allow to use a usb device with multiple interfaces. Since I need multiple interface ( I'm trying to reverse engineering an HP=20 printer/scanner device ), and the previous "multiple interface" patch is no= t=20 available anymore, I've written one. It's a really dumb patch, all it does = is=20 removing the check for multiple interface and simply grabbing every interfa= ce=20 on the device. I really don't know if it's correct but winXP see the both interface and th= e=20 HP driver see the device. I can print with it from qemu ( the printer=20 interface is N=B01, the scanner is N=B00 ) so it seems to work. Saddly I cannot scan, windows reboot ( BSOD ) after a few USB transfer ( ma= ybe=20 because windows see the device as attached on a 12Mbit/s port but the _real= _=20 device is on 480Mbit/s so the packet are comming too fast ? ). Hope it will help someone else. Regards, Couriousous --Boundary-00=_5CMNGcW9uZPM29y Content-Type: text/x-diff; charset="iso-8859-1"; name="multiple-interface.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="multiple-interface.patch" Index: qemu-0.9.0/usb-linux.c =================================================================== --- qemu-0.9.0/usb-linux.c +++ qemu-0.9.0/usb-linux.c 2007-04-28 22:02:15.000000000 +0200 @@ -186,18 +186,13 @@ if (i + config_descr_len > descr_len) goto fail; nb_interfaces = descr[i + 4]; - if (nb_interfaces != 1) { - /* NOTE: currently we grab only one interface */ - fprintf(stderr, "usb_host: only one interface supported\n"); - goto fail; - } #ifdef USBDEVFS_DISCONNECT /* earlier Linux 2.4 do not support that */ - { + for(i = 0; i < nb_interfaces; i++) { struct usbdevfs_ioctl ctrl; ctrl.ioctl_code = USBDEVFS_DISCONNECT; - ctrl.ifno = 0; + ctrl.ifno = i; ret = ioctl(fd, USBDEVFS_IOCTL, &ctrl); if (ret < 0 && errno != ENODATA) { perror("USBDEVFS_DISCONNECT"); @@ -206,18 +201,19 @@ } #endif - /* XXX: only grab if all interfaces are free */ - interface = 0; - ret = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &interface); - if (ret < 0) { - if (errno == EBUSY) { - fprintf(stderr, "usb_host: device already grabbed\n"); - } else { - perror("USBDEVFS_CLAIMINTERFACE"); - } - fail: - close(fd); - return NULL; + /* XXX: Grab every interfaces */ + for(interface = 0; interface < nb_interfaces; interface++) { + ret = ioctl(fd, USBDEVFS_CLAIMINTERFACE, &interface); + if (ret < 0) { + if (errno == EBUSY) { + fprintf(stderr, "usb_host: device already grabbed\n"); + } else { + perror("USBDEVFS_CLAIMINTERFACE"); + } +fail: + close(fd); + return NULL; + } } ret = ioctl(fd, USBDEVFS_CONNECTINFO, &ci); --Boundary-00=_5CMNGcW9uZPM29y--