From: Ruslan Bilovol <ruslan.bilovol@gmail.com>
To: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Peter Chen <peter.chen@freescale.com>,
Daniel Mack <zonque@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Ruslan Bilovol <ruslan.bilovol@gmail.com>,
<stable@vger.kernel.org>
Subject: [PATCH 1/5] usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot
Date: Wed, 17 Feb 2021 00:24:55 +0200 [thread overview]
Message-ID: <1613514299-20668-2-git-send-email-ruslan.bilovol@gmail.com> (raw)
In-Reply-To: <1613514299-20668-1-git-send-email-ruslan.bilovol@gmail.com>
As per UAC2 Audio Data Formats spec (2.3.1.1 USB Packets),
if the sampling rate is a constant, the allowable variation
of number of audio slots per virtual frame is +/- 1 audio slot.
It means that endpoint should be able to accept/send +1 audio
slot.
Previous endpoint max_packet_size calculation code
was adding sometimes +1 audio slot due to DIV_ROUND_UP
behaviour which was rounding up to closest integer.
However this doesn't work if the numbers are divisible.
It had no any impact with Linux hosts which ignore
this issue, but in case of more strict Windows it
caused rejected enumeration
Thus always add +1 audio slot to endpoint's max packet size
Fixes: 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
Cc: Peter Chen <peter.chen@freescale.com>
Cc: <stable@vger.kernel.org> #v4.3+
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
---
drivers/usb/gadget/function/f_uac2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index 740cb64..c62cccb 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -478,7 +478,7 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
}
max_size_bw = num_channels(chmask) * ssize *
- DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
+ ((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1);
ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
max_size_ep));
--
1.9.1
next prev parent reply other threads:[~2021-02-16 22:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 22:24 [PATCH 0/5] USB Audio Gadget part 1: misc fixes and improvements Ruslan Bilovol
2021-02-16 22:24 ` Ruslan Bilovol [this message]
2021-02-16 22:24 ` [PATCH 2/5] usb: gadget: f_uac1: stop playback on function disable Ruslan Bilovol
2021-02-16 22:24 ` [PATCH 3/5] usb: gadget: f_uac2: validate input parameters Ruslan Bilovol
2021-02-16 22:24 ` [PATCH 4/5] usb: gadget: f_uac1: " Ruslan Bilovol
2021-02-16 22:24 ` [PATCH 5/5] usb: gadget: f_uac1: disable IN/OUT ep if unused Ruslan Bilovol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1613514299-20668-2-git-send-email-ruslan.bilovol@gmail.com \
--to=ruslan.bilovol@gmail.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@freescale.com \
--cc=stable@vger.kernel.org \
--cc=zonque@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).