OK, turing.

<- leave blank

Wed Nov 23 22:42:36 EST 2022

Return-Path: <9front-bounces@9front.inri.net>
Delivered-To: ori@eigenstate.org
Received: from 9front.inri.net (9front.inri.net [168.235.81.73])
	by mimir.eigenstate.org (OpenSMTPD) with ESMTP id e441b628
	for <ori@eigenstate.org>;
	Fri, 18 Nov 2022 19:43:43 -0800 (PST)
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Received: from mail-pl1-f182.google.com ([209.85.214.182]) by 9front; Fri Nov 18
22:39:05 -0500 2022
Received: by mail-pl1-f182.google.com with SMTP id y4so6191833plb.2
	for <9front@9front.org>; Fri, 18 Nov 2022 19:39:02 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=mforney.org; s=google;
	h=to:subject:date:from:references:in-reply-to:message-id:from:to:cc
	 :subject:date:message-id:reply-to;
	bh=ECfPYiKkdHEReWQyUXJ+LNXrgU1SA02Xef0QBjssNl0=;
	b=H1Hoajq3WSECgJbNB0LsGAgfVodAEdgsTjWZGZx3SiP/prwYsmAA8b05G5tQj7SGZ+
	 /vJjalNnmHOtMu2z9cmE3R7Nw0ilihgeHPGagmEQzbqjKk2itDn7snp/dc+JNhkJH6Ad
	 pMoO/Qfs/G9ywMT5z7dnUKenAhZJnC4d2K/SW3Mau5Uf1AAEnUP3nPKS4xG5X46kDv97
	 Fcem241GS+k97tjsFSWIx2JpdX88Zski1lFFNhaYAGk76h5SfOXeTbCQvdArjAGAaaUJ
	 fBBhamJLzqIyZ2TTpugpnBzedhIo3YRpWkWGEeJMye/Jbs/pI+3FAfSybJTsfEYv0gA6
	 a/rw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20210112;
	h=to:subject:date:from:references:in-reply-to:message-id
	 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
	bh=ECfPYiKkdHEReWQyUXJ+LNXrgU1SA02Xef0QBjssNl0=;
	b=C4QGAyEwU9HE9zMuIxgvfUywNiLh25GR+IMDd5gZY+8XKtY1raGAerY/734tFWXli8
	 Pzh97QhIOk+qzG/WfWakH32Q99KZ9AWeO7VM9ZM5X1R7x3pyuR4JP2a8KIetuo83fUn5
	 iWKZA1+8N6uLcDacE81oUeD04KhqrHKW0wJvPWvLfU58nfeLNc6/+Sx866sHEtZtJoBc
	 +8v1QPw2jvX8ZMNBiLHZ8tWs6WdgfxlnPDVICEUHzUZN6PrCXiz7ZEBm5T/SAhiiw8CC
	 tXme6j+A0r6dnr2gCqsX9nSplGwK1+rREajgCU8wjTm87UAtY3e1Q9oFTZgF/gXKhEjp
	 9VVA==
X-Gm-Message-State: ANoB5plz9u8Ywnol9aT9GGqLnEGOMjNlP+OudD77SKpV/1kFoHJxyXlY
	FTM1zWy76jLi7K4tb921CQ1CLDTVxg6R+mNOCaY=
X-Google-Smtp-Source:
AA0mqf5BJ9AL8fQsoNUxuf8Pul2/H361O0GmC0svGw2T9NXFiLiW6yUX7+XJ4S+UN1ch8ku6kIBi8Q==
X-Received: by 2002:a17:90a:8b03:b0:213:16d2:4d4c with SMTP id
y3-20020a17090a8b0300b0021316d24d4cmr10955530pjn.70.1668829141489;
	Fri, 18 Nov 2022 19:39:01 -0800 (PST)
Return-Path: <mforney@mforney.org>
Received: from localhost ([2601:647:6400:20b0:cab2:9bff:fe88:d09c])
	by smtp.gmail.com with ESMTPSA id
	k5-20020a170902d58500b00186cd4a8aedsm4435060plh.252.2022.11.18.19.38.59
	for <9front@9front.org>
	(version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
	Fri, 18 Nov 2022 19:39:00 -0800 (PST)
Message-Id:
<c9ad1fd3751558d2c105518b869cfcd880595346.1668828454.git.mforney@mforney.org>
In-Reply-To: <cover.1668828454.git.mforney@mforney.org>
References: <cover.1668828454.git.mforney@mforney.org>
From: Michael Forney <mforney@mforney.org>
Date: Fri, 18 Nov 2022 09:11:50 +0000
To: 9front@9front.org
List-ID: <9front.9front.org>
List-Help: <http://lists.9front.org>
X-Glyph: ➈
X-Bullshit: HTML over SSL STM API database
Subject: [9front] [PATCH 3/5] nusb/audio: only consider data endpoints when
setting up
 stream
Reply-To: 9front@9front.org
Precedence: bulk

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