All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Keith A. Milner" <maillist@superlative.org>
To: alsa-devel@alsa-project.org
Subject: Re: Attempting to understand odd snd-usb-audio code and behavior
Date: Mon, 22 Jan 2018 15:40:03 +0000	[thread overview]
Message-ID: <2180450.qzCeTlsBey@kamdesktop> (raw)
In-Reply-To: <4997219.KIItTR1t2S@kamdesktop>

On Monday 22 Jan 2018 14:06:08 Keith A. Milner wrote:
> On Wednesday 23 Aug 2017 14:52:43 Clemens Ladisch wrote:
> > Keith A. Milner wrote:
> > >>> kernel: [ 1987.452947] usb 1-1: Unable to change format on ep #8e:
> > >>> already in use>
> > > 
> > > So the error messages are due to a userspace app trying to open playback
> > > and capture at the same time?
> > 
> > For this device, playback requires a running capture stream to determine
> > the rate of packets.  This error happens when the application tries to
> > open the capture stream after the playback stream.  (If the format does
> > not actually need to change, the error message is misleading.)
> > 
> > Your actual problem is that the device does not send any capture packets.
> 
> OK, I found some more time to look at this.
> 
> The background is a Roland device. The device descriptor is attached, but it
> seems to be common to a lot of Roland devices.
> 
> Specifically on this device, the Playback endpoint is 0x0d and there is a
> related Implicit feedback endpoint at 0x8e.
> 
> I have USB traces of the device operation under Windows and the (non)
> operation under Linux. The primary difference seems to be that, under
> Windows, the Implict Feedback endpoint (0x8e) is opened prior to playback
> commencing. Given previous discussions (and further research) on Implicit
> feedback, this makes sense.
> 
> Under Linux, this does not happen.
> 
> I've been studying the code in pcm.c and endpoint.c to work out why this is,
> and have some questions on the code function.
> 
> The flow of the code to deal with implict feedback setup in pcm.c is,
> roughly, as follows:
> set_sync_endpoint
>   set_sync_ep_implicit_fb_quirk
>      search_roland_implicit_fb
> 
> set_sync_ep_implicit_fb_quirk seems to deal with quirks relating to implicit
> feedback and, within this, is a specific check for Roland which ends up
> branching to "add_sync_ep" which adds a new endpoint via endpoint.c
> function snd_usb_add_endpoint and assigns this as as the sync endpoint:
> 
> 	subs->sync_endpoint = snd_usb_add_endpoint(subs->stream->chip,
> 						   alts, ep, !subs->direction,
> 						   SND_USB_ENDPOINT_TYPE_DATA);
> 
> 	subs->data_endpoint->sync_master = subs->sync_endpoint;
> 
> Within endpoint.c, this new endpoint is added to chip->ep_list :
> 
> 	list_add_tail(&ep->list, &chip->ep_list);
> 
> After set_sync_ep_implicit_fb_quirk has completed it returns to
> set_sync_endpoint which then checks that there are at least 2 endpoints:
> 
> 	if (altsd->bNumEndpoints < 2)
> 		return 0;
> 
> However, in the case I'm testing, on this device, this test fails as
> bNumEndpoints is 1, even though we've just added a second endpoint for the
> Implicit feedback.
> 
> Looking at the code, endpoint.c does not alter bNumEndpoints, which seems to
> be a fundamental piece of data held against the usb_host_interface instance
> and, presumably, set from the device descriptor by underlying kernel code.
> 
> My question is, is the test for bNumEndpoints correct here? From what I can
> gather, the whole point of the set_sync_ep_implicit_fb_quirk and
> search_roland_implicit_fb code is to add an endpoint that can then be used
> by set_sync_endpoint, but this seems to be ignored by doing the test for
> bNumEndpoints.
> 
> Or, perhaps, is it that the way that this endpoint is added is incorrect.
> 
> I have, by the way, tried commenting out the bNumEndpoints test, and it
> fails at the subsequent sync-pipe check with:
> 
> invalid sync pipe. bmAttributes 00, bLength 0, bSynchAddress 00
> 
> To me this suggests the endpoint isn't being set correctly somehow.
> 
> Any pointers gratefully received.

Answering my own question, I've just realized that the objective of 
set_sync_endpoint is to set the sync endpoint as follows:

subs->data_endpoint->sync_master = subs->sync_endpoint;

The quirks in set_sync_ep_implicit_fb_quirk do this directly, so the remainder 
of the code in set_sync_endpoint is irrelevant for these devices.

My next course of action is to try to work out why the sync endpoint doesn't 
seem to be opened.

Cheers,

Keith

  reply	other threads:[~2018-01-22 15:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 20:25 Attempting to understand odd snd-usb-audio code and behavior Keith A. Milner
2017-08-23 10:23 ` Clemens Ladisch
2017-08-23 11:25   ` Keith A. Milner
2017-08-23 12:52     ` Clemens Ladisch
2017-08-23 22:43       ` Keith A. Milner
2017-08-23 22:49       ` Keith A. Milner
2018-01-22 14:06       ` Keith A. Milner
2018-01-22 15:40         ` Keith A. Milner [this message]
2018-01-22 18:14           ` Keith A. Milner
2020-04-05  0:14             ` Re: [alsa-devel] " Ilya Dikariev
2020-08-21 12:03               ` Keith A. Milner

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=2180450.qzCeTlsBey@kamdesktop \
    --to=maillist@superlative.org \
    --cc=alsa-devel@alsa-project.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.