From patchwork Fri Jan 13 10:18:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 135823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AD478B6F13 for ; Fri, 13 Jan 2012 23:22:52 +1100 (EST) Received: from localhost ([::1]:37911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlfQv-0003b3-Bo for incoming@patchwork.ozlabs.org; Fri, 13 Jan 2012 06:36:33 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlfQY-0003Iy-Qp for qemu-devel@nongnu.org; Fri, 13 Jan 2012 06:36:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlfQU-0000Z4-A0 for qemu-devel@nongnu.org; Fri, 13 Jan 2012 06:36:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlfQT-0000Yp-P7 for qemu-devel@nongnu.org; Fri, 13 Jan 2012 06:36:06 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0DBa5Yd004352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Jan 2012 06:36:05 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0DBZxPp001607; Fri, 13 Jan 2012 06:36:01 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id E7D9F40E4F; Fri, 13 Jan 2012 11:18:34 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 13 Jan 2012 11:18:21 +0100 Message-Id: <1326449914-8591-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1326449914-8591-1-git-send-email-kraxel@redhat.com> References: <1326449914-8591-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 04/17] usb-desc: audio endpoint support 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 Add support for audio endpoints which have two more fields in the descriptor. Also add support for extra class specific endpoint descriptors. Signed-off-by: Gerd Hoffmann --- hw/usb-desc.c | 14 +++++++++++--- hw/usb-desc.h | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/usb-desc.c b/hw/usb-desc.c index b9996a1..9c38661 100644 --- a/hw/usb-desc.c +++ b/hw/usb-desc.c @@ -192,9 +192,10 @@ int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len) int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len) { - uint8_t bLength = 0x07; + uint8_t bLength = ep->is_audio ? 0x09 : 0x07; + uint8_t extralen = ep->extra ? ep->extra[0] : 0; - if (len < bLength) { + if (len < bLength + extralen) { return -1; } @@ -205,8 +206,15 @@ int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len) dest[0x04] = usb_lo(ep->wMaxPacketSize); dest[0x05] = usb_hi(ep->wMaxPacketSize); dest[0x06] = ep->bInterval; + if (ep->is_audio) { + dest[0x07] = ep->bRefresh; + dest[0x08] = ep->bSynchAddress; + } + if (ep->extra) { + memcpy(dest + bLength, ep->extra, extralen); + } - return bLength; + return bLength + extralen; } int usb_desc_other(const USBDescOther *desc, uint8_t *dest, size_t len) diff --git a/hw/usb-desc.h b/hw/usb-desc.h index 5c14e4a..d6e07ea 100644 --- a/hw/usb-desc.h +++ b/hw/usb-desc.h @@ -71,6 +71,11 @@ struct USBDescEndpoint { uint8_t bmAttributes; uint16_t wMaxPacketSize; uint8_t bInterval; + uint8_t bRefresh; + uint8_t bSynchAddress; + + uint8_t is_audio; /* has bRefresh + bSynchAddress */ + uint8_t *extra; }; struct USBDescOther {