From patchwork Tue Oct 8 19:58:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 281647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A23552C0077 for ; Wed, 9 Oct 2013 07:48:43 +1100 (EST) Received: from localhost ([::1]:38738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdV0-0008TX-If for incoming@patchwork.ozlabs.org; Tue, 08 Oct 2013 16:03:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdQX-0003Rz-3x for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:58:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTdQR-0004ti-5k for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:58:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTdQQ-0004tN-Th for qemu-devel@nongnu.org; Tue, 08 Oct 2013 15:58:35 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r98JwYif019384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Oct 2013 15:58:34 -0400 Received: from shalem.localdomain.com (vpn1-4-104.ams2.redhat.com [10.36.4.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r98JwJIK024285; Tue, 8 Oct 2013 15:58:32 -0400 From: Hans de Goede To: Gerd Hoffmann Date: Tue, 8 Oct 2013 21:58:14 +0200 Message-Id: <1381262298-3241-10-git-send-email-hdegoede@redhat.com> In-Reply-To: <1381262298-3241-1-git-send-email-hdegoede@redhat.com> References: <1381262298-3241-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 09/13] usb: Add usb_device_alloc/free_streams X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Hans de Goede --- hw/usb/bus.c | 18 ++++++++++++++++++ include/hw/usb.h | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 72d5b92..bba554c 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -203,6 +203,24 @@ void usb_device_ep_stopped(USBDevice *dev, USBEndpoint *ep) } } +int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps, + int streams) +{ + USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); + if (klass->alloc_streams) { + return klass->alloc_streams(dev, eps, nr_eps, streams); + } + return 0; +} + +void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps) +{ + USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); + if (klass->free_streams) { + klass->free_streams(dev, eps, nr_eps); + } +} + static int usb_qdev_init(DeviceState *qdev) { USBDevice *dev = USB_DEVICE(qdev); diff --git a/include/hw/usb.h b/include/hw/usb.h index e9d96ba..0a6ef4a 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -315,6 +315,14 @@ typedef struct USBDeviceClass { */ void (*ep_stopped)(USBDevice *dev, USBEndpoint *ep); + /* + * Called by the hcd to alloc / free streams on a bulk endpoint. + * Optional may be NULL. + */ + int (*alloc_streams)(USBDevice *dev, USBEndpoint **eps, int nr_eps, + int streams); + void (*free_streams)(USBDevice *dev, USBEndpoint **eps, int nr_eps); + const char *product_desc; const USBDesc *usb_desc; } USBDeviceClass; @@ -553,6 +561,10 @@ void usb_device_flush_ep_queue(USBDevice *dev, USBEndpoint *ep); void usb_device_ep_stopped(USBDevice *dev, USBEndpoint *ep); +int usb_device_alloc_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps, + int streams); +void usb_device_free_streams(USBDevice *dev, USBEndpoint **eps, int nr_eps); + const char *usb_device_get_product_desc(USBDevice *dev); const USBDesc *usb_device_get_usb_desc(USBDevice *dev);