From patchwork Mon Mar 19 01:46:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Bilovol X-Patchwork-Id: 10291603 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 6E49860386 for ; Mon, 19 Mar 2018 01:56:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ABC629048 for ; Mon, 19 Mar 2018 01:56:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 457672902E; Mon, 19 Mar 2018 01:56:11 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 8484729048 for ; Mon, 19 Mar 2018 01:56:10 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 45520267377; Mon, 19 Mar 2018 02:46:13 +0100 (CET) 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 22FB42672BA; Mon, 19 Mar 2018 02:46:10 +0100 (CET) Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by alsa0.perex.cz (Postfix) with ESMTP id 70A3A267294 for ; Mon, 19 Mar 2018 02:46:07 +0100 (CET) Received: by mail-lf0-f68.google.com with SMTP id t132-v6so23006909lfe.2 for ; Sun, 18 Mar 2018 18:46:07 -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=bUEcsY+4AX/pbDwfDIJh9wPTZGgEnXm6cgL4+GDmVys=; b=aKF1iLawFNfDNNFbBEnRd9hDvoCP/IQF165DM2FmRyJIAtxUPaehigLTdC5uSURS9Q 4bltLy1Gkdxwss5YNkLqTnE88zBzaNlMnrkq+VceY5warzIRbu5qiWK6U6NYInv9Dy6+ rx5fUHLDlqeH3S/HVoCOOIwFwhzbaao7A6om+lDQIaqScByiW6QPvEaixoeS59sXuaix qv5ghywCG5zSfgD2xYUMvI1eGKxuFGvP5hOlFkAL07nU9U9vS5FGioEu7HJ4reO2hSEo fMuxAf6HMYU9jibTDd3gVJV5mha7qQJpYi9dW0TwlGN/Pq4tcr9+gdgeiJxIJEgDls3J yLXg== 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=bUEcsY+4AX/pbDwfDIJh9wPTZGgEnXm6cgL4+GDmVys=; b=QaK83l4WsBaoB65tPCCx3xjmPy1GIyoh5WylW8Q0e5odxxjSEx3xXfgajD1QNNURJg ruOUoh1yLutpz8HXc+hySLvQ+tXxX1e1iLza3P8BGkhWLJlZvYAuwsbMgv3hnVnwcy0U TDxTs9pYGlDeNxwqS73LoxglQ9ZHOpWpo9nB7y9/U+YEXMXz9Y0bjZwLiaP5OiPl/Sf0 2QTDYrG6wFYlS/rcIy8q2h5Z/Tv0AHm74CJXXsUg8Ii1VSWtcYDkXJ8NStDco5vzMTXy wMTgQ6ONaWy87+6InuMCOKpwG1Dqm4h7Z6rRheHc9vrfw1qhX95W9gG8PVhJB23HnsXG UH5A== X-Gm-Message-State: AElRT7H71oum4M9uZF2ArgNkgK1U3cDOAhHnGdmcUjdTgCfcp5wkbZ0m d+dSb1rwkwzlVkjrwyxPwME= X-Google-Smtp-Source: AG47ELuqkJarhGrlj7fb6IZABEsy7RIg4Kk1MNFoIxwV5N/tdU40qzqfMHkc1XqMK3PhkSkzy9/pQA== X-Received: by 10.46.146.25 with SMTP id k25mr6415075ljg.100.1521423967249; Sun, 18 Mar 2018 18:46:07 -0700 (PDT) Received: from localhost ([62.216.62.149]) by smtp.gmail.com with ESMTPSA id v8sm2894506ljg.61.2018.03.18.18.46.06 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 18 Mar 2018 18:46:06 -0700 (PDT) From: Ruslan Bilovol To: Takashi Iwai Date: Mon, 19 Mar 2018 03:46:02 +0200 Message-Id: <1521423963-24677-2-git-send-email-ruslan.bilovol@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521423963-24677-1-git-send-email-ruslan.bilovol@gmail.com> References: <1521423963-24677-1-git-send-email-ruslan.bilovol@gmail.com> Cc: Jorge , alsa-devel@alsa-project.org, Pierre-Louis Bossart , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [alsa-devel] [PATCH v2 1/2] ALSA: usb-audio: move audioformat quirks to quirks.c 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 Offload USB audio interface parsing function by moving quirks to a specially designed location (quirks.c) Signed-off-by: Ruslan Bilovol --- sound/usb/quirks.c | 34 ++++++++++++++++++++++++++++++++++ sound/usb/quirks.h | 4 ++++ sound/usb/stream.c | 30 +----------------------------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index ea8f3de..eeea8e1 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1403,3 +1403,37 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, return 0; } + +void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip, + struct audioformat *fp, + int stream) +{ + switch (chip->usb_id) { + case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ + /* Optoplay sets the sample rate attribute although + * it seems not supporting it in fact. + */ + fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; + break; + case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ + case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ + /* doesn't set the sample rate attribute, but supports it */ + fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; + break; + case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */ + case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ + case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ + case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is + an older model 77d:223) */ + /* + * plantronics headset and Griffin iMic have set adaptive-in + * although it's really not... + */ + fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; + else + fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; + break; + } +} diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index b90c8b7..a80e0dd 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h @@ -42,4 +42,8 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, struct audioformat *fp, unsigned int sample_bytes); +void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip, + struct audioformat *fp, + int stream); + #endif /* __USBAUDIO_QUIRKS_H */ diff --git a/sound/usb/stream.c b/sound/usb/stream.c index d1776e5..dbbe854 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -678,35 +678,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) INIT_LIST_HEAD(&fp->list); /* some quirks for attributes here */ - - switch (chip->usb_id) { - case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ - /* Optoplay sets the sample rate attribute although - * it seems not supporting it in fact. - */ - fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; - break; - case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ - case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ - /* doesn't set the sample rate attribute, but supports it */ - fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; - break; - case USB_ID(0x0763, 0x2001): /* M-Audio Quattro USB */ - case USB_ID(0x0763, 0x2012): /* M-Audio Fast Track Pro USB */ - case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ - case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is - an older model 77d:223) */ - /* - * plantronics headset and Griffin iMic have set adaptive-in - * although it's really not... - */ - fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; - if (stream == SNDRV_PCM_STREAM_PLAYBACK) - fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; - else - fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; - break; - } + snd_usb_audioformat_attributes_quirk(chip, fp, stream); /* ok, let's parse further... */ if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream) < 0) {