From: Takashi Iwai Subject: Re: alsa problems Date: Tue, 28 Mar 2006 16:06:15 +0200 Message-ID: References: <1143547835.13615.25.camel@localhost> <1143551506.13615.48.camel@localhost> <1143552082.13615.51.camel@localhost> <1143553451.13615.57.camel@localhost> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from mx1.suse.de (mail.suse.de [195.135.220.2]) by alsa.jcu.cz (ALSA's E-mail Delivery System) with ESMTP id 55A57199 for ; Tue, 28 Mar 2006 16:06:22 +0200 (MEST) In-Reply-To: <1143553451.13615.57.camel@localhost> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Johannes Berg Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Tue, 28 Mar 2006 15:44:11 +0200, Johannes Berg wrote: > > On Tue, 2006-03-28 at 15:36 +0200, Takashi Iwai wrote: > > > > Because the pcm is created by my i2s bus driver (which knows it can only > > > have one pcm per i2s bus). > > > > What do you mean one pcm? One PCM substream, one-directional stream, > > or both one pcm instance containing playback and capture streams? > > I can have at most one pcm instance containing one playback and one > capture stream per i2s bus. > > > The question is rather the flow of creation. > > Usually, the registration occurs at the very last of initialization > > stage, i.e. all devices are probed and initialized to be ready for > > use. Then the driver calls register function. > > > > If the registration _must_ be done dynamically, one by one, the > > situation becomes a bit more complicated. It's not only to the driver > > but to the user-space things. > > Yes. It must be done dynamically. > > > > Right now it's even more broken requiring me to create both the playback > > > and capture stream without knowing if there's anything on the bus that > > > can handle it. > > > > You don't have to create an empty PCM, but create a PCM on demand, as > > usbaudio.c does. It doesn't create both streams. > > Right. > Let me explain the control flow: > > First, i2s busses are discovered, but no pcm instances created for them > yet. > > Then, codecs are discovered, and each on registers with the i2s bus it > sits on. At that point, the codec could support input only, and it > announces this to the i2s bus. Thus, the i2s bus creates a pcm with just > a capture stream, and registers it. > > Now, another codec is discovered, and it is on the same i2s bus, but > supports playback and capture. Now, my i2s layer handles switching > between which one of them gets to capture, so that's fine, but when I > now try to add a playback stream to my pcm, this playback stream never > shows up. > > [the actual situation is slightly different, but this serves well to > illustrate it and might actually happen this way in the future] > > Now, I cannot defer registration of the pcm until the second codec is > discovered because there's no way to know if a second codec even exists, > and even if it exists if the user compiled the module for it. Hm, it's indeed a complex situaton. A relatively easy workaround is to create two PCM instances, each of which is dedicated for only a single direction. Then you can define appropriate configuration in alsa-lib to choose the right PCM number. The drawbacks are about the kernel OSS emulator, as usual. Alternatively, we can create a new function, e.g. snd_pcm_register_stream(), for doing what snd_pcm_dev_register() does for a single stream. It's an exception only for PCM which may have multiple device files. I have a rough design of new PCM middle layer in my head to reduce snd_pcm struct, and it would work fine in your case. Nevertheless, it's still a vaporware :) Takashi ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642