From: Takashi Iwai Subject: Re: [PATCH 2/2] ASoC: pcm: Always honor DAI min and max sample rate constraints Date: Wed, 27 Nov 2013 14:13:21 +0100 Message-ID: References: <1385542698-13362-1-git-send-email-lars@metafoo.de> <1385542698-13362-2-git-send-email-lars@metafoo.de> <5295D500.50607@metafoo.de> <20131127122153.GU14725@sirena.org.uk> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 704D4261AA5 for ; Wed, 27 Nov 2013 14:13:22 +0100 (CET) In-Reply-To: <20131127122153.GU14725@sirena.org.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: Jean-Francois Moine , alsa-devel@alsa-project.org, Lars-Peter Clausen , Liam Girdwood List-Id: alsa-devel@alsa-project.org At Wed, 27 Nov 2013 12:21:53 +0000, Mark Brown wrote: > > On Wed, Nov 27, 2013 at 12:26:29PM +0100, Takashi Iwai wrote: > > Lars-Peter Clausen wrote: > > > > My thinking as well. There are some driver which do set CONTINUOUS or KNOT, > > > but don't specify a minimum and maximum rate and probably rely on the fact > > > that we always call snd_pcm_limit_hw_rates() (E.g. the kirkwood drivers do > > > this). In my opinion those drivers should be fixed and once that is done we > > > can add a check that skips snd_pcm_limit_hw_rates() if KNOT or CONTINUOUS is > > > set. The current behavior isn't optimal e.g. if a driver sets > > > SNDRV_PCM_RATE_CONTINUOUS and SNDRV_PCM_RATE_8000_192000 and rate_max to > > > 384000, we'd still end up with a maximum rate of 192000 because of > > > snd_pcm_limit_hw_rates(). > > > Right. We should catch all them once, then add a sanity check > > something like > > It seems neater if snd_pcm_limit_hw_rates() does the right thing no > matter what the rates are - this centralises the logic for handling this > which reduces the complexity for drivers. Well, the difficult point is to decide what is right, if the given condition is already wrong (e.g. rate_min/max don't match with the RATE bits). We can accept it somehow silently (as of now), but I think it's better to warn (and/or refuse). > > WARN_ON((rates & SNDRV_PCM_RATE_KNOT) && \ > > (rates & ~SNDRV_PCM_RATE_KNOT)); > > WARN_ON((rates & SNDRV_PCM_RATE_CONTINUOUS) && \ > > (rates & ~SNDRV_PCM_RATE_CONTINUOUS)); > > This does make sense, though we'll need to change the constraint merging > code in ASoC since right now it assumes that combining the masks will do > the merge which won't be the case if you have devices with one of these > flags together with any other flags (either specific rates or the other > non-bitmask one). It would be nice if we were just throwing the device > constraints into the core constraint code and letting it merge them > together. I think Lars' fix will handle such a case nicely now; at least, merging between RATE bits and rate_min/max is solved, as long as the given conditions are consistent. But yes, we can certainly put some sanity checks and more handling code into a core stuff. But the drivers giving wrong parameters must be fixed in anyway. IIRC, even ac97_codec.c does something misaligned. Warnings would be a help for hunting such ones, and I didn't intend it being more than that in WARN_ON() above. thanks, Takashi