From: Michael Forney <mforney@mforney.org>
To: 9front@9front.org
Subject: [9front] [PATCH 3/5] nusb/audio: only consider data endpoints when setting up stream
Date: Fri, 18 Nov 2022 09:11:50 +0000 [thread overview]
Message-ID: <c9ad1fd3751558d2c105518b869cfcd880595346.1668828454.git.mforney@mforney.org> (raw)
In-Reply-To: <cover.1668828454.git.mforney@mforney.org>
An async iso endpoint has a data endpoint and feedback endpoint, and
both get mapped to the same slot in d->usb->ep. However, when setting
up audio streams, we are only interested in the data endpoints. If
the feedback endpoint appears first in the list, we end up trying to
use feedback endpoints for audio data and ignore the data endpoints.
---
sys/src/cmd/nusb/audio/audio.c | 48 +++++++++++++++++++---------------
sys/src/cmd/nusb/lib/usb.h | 5 ++++
2 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/sys/src/cmd/nusb/audio/audio.c b/sys/src/cmd/nusb/audio/audio.c
index 66e77da713..09b84b8c48 100644
--- a/sys/src/cmd/nusb/audio/audio.c
+++ b/sys/src/cmd/nusb/audio/audio.c
@@ -231,30 +231,36 @@ main(int argc, char *argv[])
parsedescr(d->usb->ddesc[i]);
for(i = 0; i < nelem(d->usb->ep); i++){
e = d->usb->ep[i];
- if(e != nil && e->type == Eiso && e->iface->csp == CSP(Claudio, 2, 0)){
- switch(e->dir){
- case Ein:
- if(audioepin != nil)
- continue;
- audioepin = e;
- break;
- case Eout:
- if(audioepout != nil)
- continue;
- audioepout = e;
+ if(e == nil || e->type != Eiso || e->iface->csp != CSP(Claudio, 2, 0))
+ continue;
+ for(; e != nil; e = e->next){
+ if((e->attrib>>4 & 3) == Edata)
break;
- }
- if((ed = setupep(audiodev, e, audiofreq)) == nil){
- fprint(2, "setupep: %r\n");
-
- if(e == audioepin)
- audioepin = nil;
- if(e == audioepout)
- audioepout = nil;
+ }
+ if(e == nil)
+ continue;
+ switch(e->dir){
+ case Ein:
+ if(audioepin != nil)
continue;
- }
- closedev(ed);
+ audioepin = e;
+ break;
+ case Eout:
+ if(audioepout != nil)
+ continue;
+ audioepout = e;
+ break;
+ }
+ if((ed = setupep(audiodev, e, audiofreq)) == nil){
+ fprint(2, "setupep: %r\n");
+
+ if(e == audioepin)
+ audioepin = nil;
+ if(e == audioepout)
+ audioepout = nil;
+ continue;
}
+ closedev(ed);
}
if(audioepout == nil)
sysfatal("no endpoints found");
diff --git a/sys/src/cmd/nusb/lib/usb.h b/sys/src/cmd/nusb/lib/usb.h
index 6fbb7c8d50..83b6039289 100644
--- a/sys/src/cmd/nusb/lib/usb.h
+++ b/sys/src/cmd/nusb/lib/usb.h
@@ -100,6 +100,11 @@ enum {
Ebulk = 2,
Eintr = 3,
+ /* endpoint isousage */
+ Edata = 0,
+ Efeedback = 1,
+ Eimplicit = 2,
+
/* config attrib */
Cbuspowered = 1<<7,
Cselfpowered = 1<<6,
--
2.37.3
next prev parent reply other threads:[~2022-11-19 3:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-19 3:27 [9front] [PATCH 0/5] USB audio 2.0 Michael Forney
2022-11-18 9:11 ` [9front] [PATCH 1/5] nusb: move audio-specific requests to nusb/audio Michael Forney
2022-11-18 9:11 ` [9front] [PATCH 2/5] nusb/audio: remove code for bi-directional endpoint Michael Forney
2022-11-18 9:11 ` Michael Forney [this message]
2022-11-18 9:21 ` [9front] [PATCH 4/5] nusb/audio: enumerate streams through control interface Michael Forney
2022-11-18 20:35 ` [9front] [PATCH 5/5] nusb/audio: add support for USB audio 2.0 Michael Forney
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=c9ad1fd3751558d2c105518b869cfcd880595346.1668828454.git.mforney@mforney.org \
--to=mforney@mforney.org \
--cc=9front@9front.org \
/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).