From patchwork Wed Apr 18 14:35:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Aguirre X-Patchwork-Id: 10348247 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A52560365 for ; Wed, 18 Apr 2018 14:42:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AFED23B23 for ; Wed, 18 Apr 2018 14:42:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F9FA286F4; Wed, 18 Apr 2018 14:42:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53E8923B23 for ; Wed, 18 Apr 2018 14:42:06 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 33E79267674; Wed, 18 Apr 2018 16:35:50 +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 8367E267659; Wed, 18 Apr 2018 16:35:46 +0200 (CEST) Received: from mail-oi0-f67.google.com (mail-oi0-f67.google.com [209.85.218.67]) by alsa0.perex.cz (Postfix) with ESMTP id A91B0267650 for ; Wed, 18 Apr 2018 16:35:44 +0200 (CEST) Received: by mail-oi0-f67.google.com with SMTP id 188-v6so1772923oih.8 for ; Wed, 18 Apr 2018 07:35:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a8BD8pqeODssdCNtOi3gijlkjeX9K97vXS+n97+mD48=; b=QX7O7xfGnGAi0Ysov52FE1NfE2DaOa36OxhKsHUVQBE07lLf9dOBFTm5tmfk2t2Uz6 TtjbxLCseCObSDTUsIhXEDpg/phDj+XiI859vneKkd/Aphj9PCtrUaaroem0v836pCG/ KxRdr0/PmLurxV/8ATM52X5ISq7HgJ471bytx4naMpLf+GGKvSeXfWyiUceJZvyhK5qs fSvHIivu3Ql3TFlY5eMMBDqv/t69teg7FHbGMdf9wTb4IrPujQcr0/jqk2Xi7FOIFDKD i3xsfK8jfclw3bN5BZ8088D7x/hGb3ZH4rsKGZdB+wJht/p97AiXuCSWWuoFob2i/vob EENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a8BD8pqeODssdCNtOi3gijlkjeX9K97vXS+n97+mD48=; b=EyaGaEKqCTojY7Hy6Xmt3wAl1elBQd9bIqjr+jZyy2fW5T9PyqcYb2AaKhpcbd5+5L MsZ5GkCjRwfCvcfOUMrmi+qHEUyk+WPK8CXNlvqhcfba9XnZXSyVc3qndlOXqGvIUBgL HNuuK5PXBwtjHDvGJZyGWTGAlWo+E1sTyFbZLcGxwPQ2zHXaIiyFrNZRksq8WIIuOeOF n2qLIVhVMe2DNhgez1Hz2sCy+05sj4xKMmkX/LhyoXQ1xaqTfibwRkiy2fiKeysjc+62 WU9KzFB9E8x+BPbWkfTjyRUZ/i+XwxJn8y1XQddxeqCltG7L8QWjaRl6piF8uGH4oV0v +6ew== X-Gm-Message-State: ALQs6tBR3jkzd3lu5wraXlxujiVqOJEy5dMjHgJ9Y7G2N/8kdBJwxR7R Qj9sj2F5q/uxoNvJTRsWwKjn4Q== X-Google-Smtp-Source: AB8JxZq6tdwoaXMVLfwN56RLlrA9x0nt8cmry0yP0t/ePS0vVu1Hep/nfmEZ3ZVfkpDgRdBtbGLDiQ== X-Received: by 2002:a54:4382:: with SMTP id u2-v6mr1221000oiv.52.1524062143484; Wed, 18 Apr 2018 07:35:43 -0700 (PDT) Received: from scorpion.lan (cpe-72-190-126-231.tx.res.rr.com. [72.190.126.231]) by smtp.gmail.com with ESMTPSA id h3-v6sm762646ote.72.2018.04.18.07.35.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 07:35:42 -0700 (PDT) From: Alberto Aguirre To: alsa-devel@alsa-project.org Date: Wed, 18 Apr 2018 09:35:34 -0500 Message-Id: <20180418143535.11097-2-albaguirre@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180418143535.11097-1-albaguirre@gmail.com> References: <20180418143535.11097-1-albaguirre@gmail.com> Cc: Alberto Aguirre Subject: [alsa-devel] [PATCH 1/2] ALSA: usb-audio: simplify set_sync_ep_implicit_fb_quirk 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 Signed-off-by: Alberto Aguirre --- sound/usb/pcm.c | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 3cbfae6604f9..c0746cc20ac4 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -321,6 +321,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, struct usb_host_interface *alts; struct usb_interface *iface; unsigned int ep; + unsigned int ifnum; /* Implicit feedback sync EPs consumers are always playback EPs */ if (subs->direction != SNDRV_PCM_STREAM_PLAYBACK) @@ -330,44 +331,23 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */ ep = 0x81; - iface = usb_ifnum_to_if(dev, 3); - - if (!iface || iface->num_altsetting == 0) - return -EINVAL; - - alts = &iface->altsetting[1]; - goto add_sync_ep; - break; + ifnum = 3; + goto add_sync_ep_from_ifnum; case USB_ID(0x0763, 0x2080): /* M-Audio FastTrack Ultra */ case USB_ID(0x0763, 0x2081): ep = 0x81; - iface = usb_ifnum_to_if(dev, 2); - - if (!iface || iface->num_altsetting == 0) - return -EINVAL; - - alts = &iface->altsetting[1]; - goto add_sync_ep; - case USB_ID(0x2466, 0x8003): + ifnum = 2; + goto add_sync_ep_from_ifnum; + case USB_ID(0x2466, 0x8003): /* Fractal Audio Axe-Fx II */ ep = 0x86; - iface = usb_ifnum_to_if(dev, 2); - - if (!iface || iface->num_altsetting == 0) - return -EINVAL; - - alts = &iface->altsetting[1]; - goto add_sync_ep; - case USB_ID(0x1397, 0x0002): + ifnum = 2; + goto add_sync_ep_from_ifnum; + case USB_ID(0x1397, 0x0002): /* Behringer UFX1204 */ ep = 0x81; - iface = usb_ifnum_to_if(dev, 1); - - if (!iface || iface->num_altsetting == 0) - return -EINVAL; - - alts = &iface->altsetting[1]; - goto add_sync_ep; - + ifnum = 1; + goto add_sync_ep_from_ifnum; } + if (attr == USB_ENDPOINT_SYNC_ASYNC && altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC && altsd->bInterfaceProtocol == 2 && @@ -382,6 +362,14 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, /* No quirk */ return 0; +add_sync_ep_from_ifnum: + iface = usb_ifnum_to_if(dev, ifnum); + + if (!iface || iface->num_altsetting == 0) + return -EINVAL; + + alts = &iface->altsetting[1]; + add_sync_ep: subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip, alts, ep, !subs->direction,