Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5263455ybi; Sun, 7 Jul 2019 01:38:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzWE6RKGtG2EweH1o4wa+RsvowYsLDeIabD0NM+XVbz/PRGKLlmKaNE3tbTIvNvbOvUGKr X-Received: by 2002:a17:90a:2ec1:: with SMTP id h1mr16141647pjs.101.1562488721040; Sun, 07 Jul 2019 01:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562488721; cv=none; d=google.com; s=arc-20160816; b=UvHymbtSHJy62TXUeOyRqq32aeFJyooBRtb6sws731/0y9iiCZhBvvvwkUCA0mGRTh Bg/QCYC+cPAbh9f6oqwW892gqCTCKxLvVh79oZWHwTdbuHxVnOsrpTE299KgXeA36aoh ksMoak2csOSDi1rlimpYo9Yocf1cpkG9EuYsOOEJH+nSpeF8nGeZYAXjxSZq1x5rtgZw XQS74vgSTFj2Q2oZZSuACKLfjMF/zER22PcqnOPMTt52WQyDLs4AbsX4f5ce2Ia7I6Hv nNvzAwY8d+W5bfeWFrHOiANGR0moLsaopd6JtJXUx0PKRN//ZXE5ieg+p4/6KM59rGZB 0v/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=G0Y4cjzHcvVmq7KzUPJtwccJDPm0PfTiZlto8ZH/pcY=; b=SUGnx5lp7MPnXUheiN90Tf7Jhuqpg/bS/dTooyl6Xp8n5dOGrnxKVdc589AWTRNRgL e/IFGTHodZol8zFJI+/Of1IoFdTa9rJ42P9Zv6FFYlRaxvF6nu5iI8Oitykqn0f1oNT2 6B3wUHvFoiRk0plSDf8K+PWcy0MDmstVQzyd8sPmeVw6dRSzmodm4tTWpExSz+XUDSLl +n8X5OB19VnuIQphr5sv6ZCwVaItBw8xUiKZhBx+yl7M5f0Is8YOKmi50D014DjZR9k+ VWTEPQBJEUR0HDh1QawM8C+BBoE3ZO4lyRp8vacWSHu12hFEp9PfTIWzS1gN83Wfn/KX dw5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RtK4rURu; 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 t15si4214912ply.162.2019.07.07.01.37.57; Sun, 07 Jul 2019 01:38:41 -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=RtK4rURu; 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 S1727232AbfGGI2U (ORCPT + 99 others); Sun, 7 Jul 2019 04:28:20 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:36171 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725822AbfGGI2U (ORCPT ); Sun, 7 Jul 2019 04:28:20 -0400 Received: by mail-ed1-f65.google.com with SMTP id k21so11713343edq.3 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=CCQpTSriBXIF3FzFalo3VjgjFl+2k3kMcMru4d9Pl+UB6V+9NOPA4efg5RUPpRIvku jHS5ej42VHtQXCpC0NF/Wzg7lHsFDvi0ioAeaqGLjrImEdNpOc8WDr95BECAqViNEnZt RQmeZMHaVya88isBHdn5xeDQhwHq6F0joSvUSfhKY7Kz7VsTDN3eVOE12IeWzMI3RCPp 5rsmTX9i+ev2i9qBSxQSq7rOqgmDTsVHchxMms6cXOQMU3QjGEvL826G1vKLxaIVRAed nYKnvZTM6YPLy6wkZ10oMIdpWQ3OhZQQo2q7W4JJISEqHGiJjIxyrJ4W7mg6aXiygK3I bONw== X-Gm-Message-State: APjAAAUU4anecP1SVvRDeatdt2Fngg3OVIcE+xAdQWhDaXabuThRX1Lo B5l4VRmEj0Dv+jUQZEdDDWs= 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 Cc: Nicola Lunghi , Jaroslav Kysela , Takashi Iwai , Greg Kroah-Hartman , Allison Randal , Jussi Laako , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH v2] ALSA: usb-audio: fix Line6 Helix audio format rates 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.19.1