Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4147772pxb; Mon, 27 Sep 2021 10:21:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZatoP+cc6jAz8NAY/oBLfhF7j5T9thE7lAGREiDADipTAc9nhpOSpjZLZ2UuqRxwHpxb9 X-Received: by 2002:a17:906:39d8:: with SMTP id i24mr1307699eje.49.1632763292490; Mon, 27 Sep 2021 10:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763292; cv=none; d=google.com; s=arc-20160816; b=IKaqvPGnERFx2v5L9hNwynVmoipsVKdb9o0zVAkTNevTC5GPriIKoY8GGyPAxJj3X2 ClP3NAOgFCEC4Wz8mlcvj3ROsuShpUP440DIDhFxedaIYcXSsVrIxcvzWnjDsN7L6sO3 +p6muTvsf3/d3Z7BF+qiYuTx7Z74JxPhYErm7jOIDw/e64SRP9kkj0J7/PN1TLX/Qlby 1e6kLVMR5yjuvFq57rLm7Hofl/pcbU5ctiydcPP16Yzk8mkqy5ZlraUyF1wvyd4UUI1R ipa5PByaGuS3GJokChpbuxjOWsErSY1VibeMBCygu27c1bc0Gz6obmtUyKN0jJXmzESS /7QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TBl2bOy/9xraM9wu0Mb/how/AaSLgumLUIxkT+xj0XQ=; b=dZrtmy53P1ArvXI0Y8XmFuq+s9rH3NRNST6VeyfnUFcCwUnz9K40uL+mCYYQa0bdHL Po/Ur2ZD/08q+ZvmexxJnnwXdABMl9i6ArIcswMGHLT//2QR41WeRckXD+vgqlQvPvzE 6lTRSSdEiQ1VkSTbAsVhSZBadjdRi/h9yFk5cut+Lt4AqIlAiVf7j+Jlwxb7HBJfUwrB d13GVWIIG94IOTaRpwtuYKZal4Kd18sVYuFpcht3xtEv/RiNF3AEecY5pLfHWYx4LvDG GCG5bF46j+hZVG/NH6ueBO1SMl8GF+quy7AaOyO/7GEYR8XRYBgS+wONxCrX/gwcb0eS UHfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pQNy8Qio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si19109064ejs.755.2021.09.27.10.20.58; Mon, 27 Sep 2021 10:21:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pQNy8Qio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236981AbhI0RVH (ORCPT + 99 others); Mon, 27 Sep 2021 13:21:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:56098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236747AbhI0RRY (ORCPT ); Mon, 27 Sep 2021 13:17:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 440EE611C2; Mon, 27 Sep 2021 17:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762706; bh=OBKzlLp2AMiJkC09jKb5ImBnds8wvxcoJV1WgITTGsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQNy8QiozOdc71qBI4rnkMByZuZDqrNQDXXP7PSifh6A+FBMOAsDmWgTBQaJjvz/5 wtqlCp+QElZths8vcKqnqvayleJmUaz9sujlnMgBRpYJom/XYYc3rQJk/Wef9Sdx2U fIgMs8a1XLqebe+Hc+VrEXDBkgQy0QaTf1bTLbbI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Henrik Enquist , Pavel Hofman Subject: [PATCH 5.14 006/162] usb: gadget: u_audio: EP-OUT bInterval in fback frequency Date: Mon, 27 Sep 2021 19:00:52 +0200 Message-Id: <20210927170233.679153722@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170233.453060397@linuxfoundation.org> References: <20210927170233.453060397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Hofman commit f5dfd98a80ff8d50cf4ae2820857d7f5a46cbab9 upstream. The patch increases the bitshift in feedback frequency calculation with EP-OUT bInterval value. Tests have revealed that Win10 and OSX UAC2 drivers require the feedback frequency to be based on the actual packet interval instead of on the USB2 microframe. Otherwise they ignore the feedback value. Linux snd-usb-audio driver detects the applied bitshift automatically. Tested-by: Henrik Enquist Signed-off-by: Pavel Hofman Cc: stable Link: https://lore.kernel.org/r/20210906130822.12256-1-pavel.hofman@ivitera.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_audio.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/usb/gadget/function/u_audio.c +++ b/drivers/usb/gadget/function/u_audio.c @@ -76,11 +76,13 @@ static const struct snd_pcm_hardware uac }; static void u_audio_set_fback_frequency(enum usb_device_speed speed, + struct usb_ep *out_ep, unsigned long long freq, unsigned int pitch, void *buf) { u32 ff = 0; + const struct usb_endpoint_descriptor *ep_desc; /* * Because the pitch base is 1000000, the final divider here @@ -108,8 +110,13 @@ static void u_audio_set_fback_frequency( * byte fromat (that is Q16.16) * * ff = (freq << 16) / 8000 + * + * Win10 and OSX UAC2 drivers require number of samples per packet + * in order to honor the feedback value. + * Linux snd-usb-audio detects the applied bit-shift automatically. */ - freq <<= 4; + ep_desc = out_ep->desc; + freq <<= 4 + (ep_desc->bInterval - 1); } ff = DIV_ROUND_CLOSEST_ULL((freq * pitch), 1953125); @@ -247,7 +254,7 @@ static void u_audio_iso_fback_complete(s pr_debug("%s: iso_complete status(%d) %d/%d\n", __func__, status, req->actual, req->length); - u_audio_set_fback_frequency(audio_dev->gadget->speed, + u_audio_set_fback_frequency(audio_dev->gadget->speed, audio_dev->out_ep, params->c_srate, prm->pitch, req->buf); @@ -506,7 +513,7 @@ int u_audio_start_capture(struct g_audio * be meauserd at start of playback */ prm->pitch = 1000000; - u_audio_set_fback_frequency(audio_dev->gadget->speed, + u_audio_set_fback_frequency(audio_dev->gadget->speed, ep, params->c_srate, prm->pitch, req_fback->buf);