From patchwork Sun Jul 7 08:27:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Lunghi X-Patchwork-Id: 11034067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFB5513BD for ; Sun, 7 Jul 2019 08:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A371F27D29 for ; Sun, 7 Jul 2019 08:29:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9427428468; Sun, 7 Jul 2019 08:29:21 +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.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8176627D29 for ; Sun, 7 Jul 2019 08:29:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D98921665; Sun, 7 Jul 2019 10:28:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D98921665 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1562488157; bh=z8jgI8BTxD92Xu6jttZWT8bhPejokv6Kwn7bwuYBuC0=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=e5051NtF9a44byGJAexc7U/g2TWhzvWbONIKADHrgohdzBk3+bJW4n0aKDq3u4z4N HTiZ3EgEQl+M40y39TfTrjG84yxsBI2iLWON4v/fzfD2K/lSSRFH2RO44JBA4PC7nR hhhx6xIFZVNX6GJAuZdkP6wGn5+9wbvbk1EZr9iQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5E21BF800E6; Sun, 7 Jul 2019 10:28:27 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27A7EF80212; Sun, 7 Jul 2019 10:28:23 +0200 (CEST) Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 498A6F800E6 for ; Sun, 7 Jul 2019 10:28:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 498A6F800E6 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RtK4rURu" Received: by mail-ed1-x542.google.com with SMTP id e3so11688247edr.10 for ; Sun, 07 Jul 2019 01:28:19 -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:mime-version :content-transfer-encoding; bh=G0Y4cjzHcvVmq7KzUPJtwccJDPm0PfTiZlto8ZH/pcY=; b=RtK4rURu7nLX5Xm5CJI5KcPO8pT1dFNz89scG04MqjKRRPCfo09V7gJM5OrXuVL+mW iPncJ22lQ30pMj8eqEJ5ETrFw4zOyW/8ReKLWPP+uG/2MmbutDotykioZGPj75U3n9sJ WhtRTFAVAkx+dY/otRi2D+e+UoRGLwxCcMR1S0qZvWFiAjYNO6uo9gJItnKT2cVEy1vu lzRwOMmwYARZw1QzLRE9z+KUkXOByH3GAdAVETVY32l1fRiofyZ06VttaMw6armI83I2 eddp0QS3BMww5M+P7YaQaTd/ORM8jCKSIWLGCTadqc65oGtX9Soop5ZYWTHLYgFVqaZh roEA== 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:mime-version :content-transfer-encoding; bh=G0Y4cjzHcvVmq7KzUPJtwccJDPm0PfTiZlto8ZH/pcY=; b=b0N4yDx8G5oZfJa4/m5ugtd/ERstECBdkXcmO5v37yXhP13w9Xv9TSIgl5akbKiACo QlXZ2ppI5GCMBIo3ur9yaUf1eGT0JPRLsY903X/0rgUef0PC8nvR4jMYOvoECQmAGujZ uUia8hPmW1nFmv1xwEa+0twc63BMOKtOb1utqj90zQwE3/zjcGC1QNEJ3/ehTipGyhV2 YC9BTS7JwbJ9nXRZPZ6sAtcvN1xmpE0fUMpql+yhoQgtnXkB7KZICi49a+54VZqit9tS Ql8QkUiT/1VAESJFBJ3U/3CyTw+8BM6kMlfKz1iMWSJk+qXOcR4gyGCVv6yMDzahAPOY la9g== X-Gm-Message-State: APjAAAXY9DZKgjVK0SWAz4OY0Am2cdWz5hQDf1lNGNjSUG7EwfLVhhDu i2VOidbz4sz2L5G61YWVxRed5KbY X-Google-Smtp-Source: APXvYqz3d0o/dxMwjKXSjP1Hn81Xq3lQXc01OhqkuNRzl+3D7bHeT3vTeiabg41E4MLogAZUnAa8hg== X-Received: by 2002:a17:906:3956:: with SMTP id g22mr11068919eje.292.1562488098545; Sun, 07 Jul 2019 01:28:18 -0700 (PDT) Received: from localhost.localdomain ([89.100.119.28]) by smtp.gmail.com with ESMTPSA id z16sm2659249eji.31.2019.07.07.01.28.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 07 Jul 2019 01:28:17 -0700 (PDT) From: Nicola Lunghi To: alsa-devel@alsa-project.org Date: Sun, 7 Jul 2019 09:27:34 +0100 Message-Id: <20190707082734.25829-1-nick83ola@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Cc: Jussi Laako , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Takashi Iwai , Thomas Gleixner , Nicola Lunghi , Allison Randal Subject: [alsa-devel] [PATCH v2] ALSA: usb-audio: fix Line6 Helix audio format rates X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Line6 Helix and HX stomp devices don't support retrieving the number of clock sample rate. Add a quirk to set it to 48Khz by default. Signed-off-by: Nicola Lunghi --- sound/usb/format.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/sound/usb/format.c b/sound/usb/format.c index c02b51a82775..31780dfb8eb9 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -285,6 +285,33 @@ static int parse_uac2_sample_rate_range(struct snd_usb_audio *chip, return nr_rates; } +/* Line6 Helix series don't support the UAC2_CS_RANGE usb function + * call. Return a static table of known clock rates. + */ +static int line6_parse_audio_format_rates_quirk(struct snd_usb_audio *chip, + struct audioformat *fp) +{ + switch (chip->usb_id) { + case USB_ID(0x0E41, 0x4241): /* Line6 Helix */ + case USB_ID(0x0E41, 0x4242): /* Line6 Helix Rack */ + case USB_ID(0x0E41, 0x4244): /* Line6 Helix LT */ + case USB_ID(0x0E41, 0x4246): /* Line6 HX-Stomp */ + /* supported rates: 48Khz */ + kfree(fp->rate_table); + fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); + if (!fp->rate_table) + return -ENOMEM; + fp->nr_rates = 1; + fp->rate_min = 48000; + fp->rate_max = 48000; + fp->rates = SNDRV_PCM_RATE_48000; + fp->rate_table[0] = 48000; + return 0; + } + + return -ENODEV; +} + /* * parse the format descriptor and stores the possible sample rates * on the audioformat table (audio class v2 and v3). @@ -294,7 +321,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, { struct usb_device *dev = chip->dev; unsigned char tmp[2], *data; - int nr_triplets, data_size, ret = 0; + int nr_triplets, data_size, ret, ret_l6 = 0; int clock = snd_usb_clock_find_source(chip, fp->protocol, fp->clock, false); @@ -313,9 +340,22 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, tmp, sizeof(tmp)); if (ret < 0) { - dev_err(&dev->dev, - "%s(): unable to retrieve number of sample rates (clock %d)\n", + /* line6 helix devices don't support UAC2_CS_CONTROL_SAM_FREQ call */ + ret_l6 = line6_parse_audio_format_rates_quirk(chip, fp); + if (ret_l6 == -ENODEV) { + /* no line6 device found continue showing the error */ + dev_err(&dev->dev, + "%s(): unable to retrieve number of sample rates (clock %d)\n", + __func__, clock); + goto err; + } + if (ret_l6 == 0) { + dev_info(&dev->dev, + "%s(): unable to retrieve number of sample rates: set it to a predefined value (clock %d).\n", __func__, clock); + return 0; + } + ret = ret_l6; goto err; }