Received: by 10.213.65.68 with SMTP id h4csp1193586imn; Sun, 18 Mar 2018 18:58:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKAH/th+LdxQmrQKJSyDtk7fdrxrAzIYpHELxI3IF4UlcwCuNPHNk8Z3cYewsIcaXvj3wO X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr10498796pls.267.1521424724384; Sun, 18 Mar 2018 18:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521424724; cv=none; d=google.com; s=arc-20160816; b=jusE6LqjOwc03np+puGLe8S8lU3kinOfXtIGoTLzBJK2Zjh/MTjrl4ughqySBGozOr VuoCYXzoO0BruyjFH3/q98tiI/CNVQJmSxbrxtlojxmQujdvTKomuJKeX82VxXCj3SeR vYbLygnts8/kng1lp0gcSu7Fwt6PPUo+jNcWuixjwq9Y/zGw3zxCdlcDgSB+7I5PYqB8 K7fDpsoMcaGBlMVRxHuQhl8MS7aMQF4f1Qb23RA41lfWU9eRkCAm0Ia4xfCXjm2KEihx hQSse2/MgFPgF5WN/GCvqXqlL0G82M1XUpuo35Ji0EgIuaymjSJcsnRBK+9huWf7p3Xw 9BJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=bUEcsY+4AX/pbDwfDIJh9wPTZGgEnXm6cgL4+GDmVys=; b=B/Uj5V6U6JrnuIhsKtJZNyB3yunOWbj4JoftI69wkKif8u/cwY5/bq/CvU98bk26w0 8z8KBT6FiwRsV3+3wh0+HYssRq/nQf+TWeJjmAmb90hPukkVEjRBK4801rBu7f9xMJTZ tv5CGj2puBkjpqLdVnREwGmwlqWLxO9V4mlhl8iHTuqtGzpL6MAutJQusvbtfV1tB4Iy 41LDwTUM2u7BRGIaNj8z4GUGZggiyCmQLvvrrXGMVuPngoOu4EqosljtFl+D0KnRRr0Z okXoLqQpcpdmtHXbR9443CoFp0RwavPetcdqApaTxnr5jfLlugqsx8UQFz+LdGP3Gu8z 57rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aKF1iLaw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si8831492pgq.293.2018.03.18.18.58.30; Sun, 18 Mar 2018 18:58:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aKF1iLaw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755072AbeCSBqR (ORCPT + 99 others); Sun, 18 Mar 2018 21:46:17 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39546 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754841AbeCSBqI (ORCPT ); Sun, 18 Mar 2018 21:46:08 -0400 Received: by mail-lf0-f65.google.com with SMTP id p142-v6so304994lfd.6 for ; Sun, 18 Mar 2018 18:46:08 -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=XMMCI8U609ITJIdfUPM2hGP0djRNAePz7rdtHC8fHtMFbrhEbjBqyAhoFXvG86T2vI iOzfG8M0AmoFnnbVnQM88ZyQtrpHJPuqRORohaXNdABonxajyH0G2/LcX2sAexWpVJr8 heiwc2uscGO6q/WHV6Vx+9wxD+29KFeZLgqVocDoBqipBgSmu//+Fl3ziPRp1l1e5V4n b6SX2S91rskhSpJmnXxFHN23+SXZxHwB8l6IWE1YDrqysKkdpx9t92kRiPppiBjWiluR Vrx7zs4nluNkvWCuCVYPgXAr4FSBwIpw7PsPeePgJv3K261x1h0L4957PkU3I9OREboG jrHg== X-Gm-Message-State: AElRT7FJSS+3JQeZg9NOQZomzrU9FjfcljSjNvEy+6V5BtSXiLPURenW HMNoogdLnz0oiEKWUOszz2U= 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 Cc: Pierre-Louis Bossart , Jorge , Greg Kroah-Hartman , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] ALSA: usb-audio: move audioformat quirks to quirks.c 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 1.9.1