From patchwork Mon Oct 19 06:52:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricard Wanderlof X-Patchwork-Id: 7433861 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BE940BEEA4 for ; Mon, 19 Oct 2015 06:56:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3E4F206F3 for ; Mon, 19 Oct 2015 06:56:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9E28D206F0 for ; Mon, 19 Oct 2015 06:56:32 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id BC461265AB6; Mon, 19 Oct 2015 08:56:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 44B5326580B; Mon, 19 Oct 2015 08:53:23 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 29A5626580B; Mon, 19 Oct 2015 08:53:22 +0200 (CEST) Received: from bes.se.axis.com (bes.se.axis.com [195.60.68.10]) by alsa0.perex.cz (Postfix) with ESMTP id B40DA265743 for ; Mon, 19 Oct 2015 08:53:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bes.se.axis.com (Postfix) with ESMTP id 8760E2E45B; Mon, 19 Oct 2015 08:53:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bes.se.axis.com Received: from bes.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bes.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id FUgbT-GrIkfu; Mon, 19 Oct 2015 08:53:04 +0200 (CEST) Received: from boulder.se.axis.com (boulder.se.axis.com [10.0.2.104]) by bes.se.axis.com (Postfix) with ESMTP id 77F0E2E466; Mon, 19 Oct 2015 08:53:04 +0200 (CEST) Received: from boulder.se.axis.com (localhost [127.0.0.1]) by postfix.imss71 (Postfix) with ESMTP id 4E0191508; Mon, 19 Oct 2015 08:53:04 +0200 (CEST) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by boulder.se.axis.com (Postfix) with ESMTP id 41D7914F8; Mon, 19 Oct 2015 08:53:04 +0200 (CEST) Received: from lnxricardw1.se.axis.com (lnxricardw1.se.axis.com [10.88.7.2]) by thoth.se.axis.com (Postfix) with ESMTP id 3E2C03404E; Mon, 19 Oct 2015 08:53:04 +0200 (CEST) Received: by lnxricardw1.se.axis.com (Postfix, from userid 9470) id 3CA615407A; Mon, 19 Oct 2015 08:53:04 +0200 (CEST) From: Ricard Wanderlof To: alsa-devel Date: Mon, 19 Oct 2015 08:52:51 +0200 Message-Id: <1445237575-396-4-git-send-email-ricardw@axis.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1445237575-396-1-git-send-email-ricardw@axis.com> References: <1444906657-16791-1-git-send-email-ricardw@axis.com> <1445237575-396-1-git-send-email-ricardw@axis.com> Cc: Takashi Iwai , Ricard Wanderlof , Ricard Wanderlof Subject: [alsa-devel] [PATCH v2 3/7] ALSA: USB-audio: Break out creation of silent urbs from prepare_outbound_urb() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Refactoring in preparation for adding Zoom R16/24 quirk. No functional change. Signed-off-by: Ricard Wanderlof --- sound/usb/endpoint.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index a77d9c8..825a06c 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -183,13 +183,38 @@ static void retire_inbound_urb(struct snd_usb_endpoint *ep, ep->retire_data_urb(ep->data_subs, urb); } +static void prepare_silent_urb(struct snd_usb_endpoint *ep, + struct snd_urb_ctx *ctx) +{ + struct urb *urb = ctx->urb; + unsigned int offs = 0; + int i; + + for (i = 0; i < ctx->packets; ++i) { + int counts; + + if (ctx->packet_size[i]) + counts = ctx->packet_size[i]; + else + counts = snd_usb_endpoint_next_packet_size(ep); + + urb->iso_frame_desc[i].offset = offs * ep->stride; + urb->iso_frame_desc[i].length = counts * ep->stride; + offs += counts; + } + + urb->number_of_packets = ctx->packets; + urb->transfer_buffer_length = offs * ep->stride; + memset(urb->transfer_buffer, ep->silence_value, + offs * ep->stride); +} + /* * Prepare a PLAYBACK urb for submission to the bus. */ static void prepare_outbound_urb(struct snd_usb_endpoint *ep, struct snd_urb_ctx *ctx) { - int i; struct urb *urb = ctx->urb; unsigned char *cp = urb->transfer_buffer; @@ -201,24 +226,7 @@ static void prepare_outbound_urb(struct snd_usb_endpoint *ep, ep->prepare_data_urb(ep->data_subs, urb); } else { /* no data provider, so send silence */ - unsigned int offs = 0; - for (i = 0; i < ctx->packets; ++i) { - int counts; - - if (ctx->packet_size[i]) - counts = ctx->packet_size[i]; - else - counts = snd_usb_endpoint_next_packet_size(ep); - - urb->iso_frame_desc[i].offset = offs * ep->stride; - urb->iso_frame_desc[i].length = counts * ep->stride; - offs += counts; - } - - urb->number_of_packets = ctx->packets; - urb->transfer_buffer_length = offs * ep->stride; - memset(urb->transfer_buffer, ep->silence_value, - offs * ep->stride); + prepare_silent_urb(ep, ctx); } break;