Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ED83C10DCE for ; Thu, 12 Mar 2020 23:20:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D078D206F1 for ; Thu, 12 Mar 2020 23:20:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="LA7dnb48" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D078D206F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=flatmax.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2491B1774; Fri, 13 Mar 2020 00:19:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2491B1774 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1584055210; bh=1C0ZyWhZmRn3ZU+82IxzHtKtwFbm75/2Z54AGK4EIHc=; h=Subject:To:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LA7dnb48trbxJJ39CmsDQntuk9xmo663MRx20CKfzFbm45+gViVHngTCes2z333JO QEVusFr5GgM+5iW0oS+dF+DyHLKI+uEnMkG1GmwVIrsys6bIFR3PmlfnSbtA7h3njI jfa22li740LtjHypdYk0spuxapJTB1GVbF4495v8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A7FD4F801D9; Fri, 13 Mar 2020 00:19:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B7226F8020C; Fri, 13 Mar 2020 00:19:17 +0100 (CET) Received: from mx.flatmax.org (mx.flatmax.org [13.55.16.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C606FF800BE for ; Fri, 13 Mar 2020 00:19:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C606FF800BE Received: from 41.68.233.220.static.exetel.com.au ([220.233.68.41] helo=[192.168.1.51]) by mx.flatmax.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jCX6Y-0004ME-Bs; Fri, 13 Mar 2020 10:19:07 +1100 Subject: Re: ASoc: soc_core.c stream direction from snd_soc_dai To: Pierre-Louis Bossart , alsa-devel@alsa-project.org References: <5598a2fc-9b49-ad5e-2265-fbc0593ead1b@flatmax.org> <0d9a9459-9cd7-d384-b1ff-72860895ad13@linux.intel.com> From: Matt Flax Message-ID: <73148789-58f7-2228-ae42-465cdafcff4c@flatmax.org> Date: Fri, 13 Mar 2020 10:19:06 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <0d9a9459-9cd7-d384-b1ff-72860895ad13@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On 13/3/20 9:55 am, Pierre-Louis Bossart wrote: > > > On 3/11/20 5:54 PM, Matt Flax wrote: >> Hi there, >> >> A large number of audio codecs allow different formats for playback >> and capture. This becomes very useful when there are different >> latencies between playback and capture hardware data lines. For >> example digital isolation chips typically have a 1 bit delay in >> propagation as the bit clock rate gets faster for higher sample >> rates. By setting the capture and playback formats to differ by one >> or two bit clock cycles, the delay problem is solved. >> >> There doesn't seem to be a simple way to detect stream direction in >> the codec driver's set_fmt function. >> >> The snd_soc_runtime_set_dai_fmt function : >> >> https://github.com/torvalds/linux/blob/master/sound/soc/soc-core.c#L1480 >> >> calls the snd_soc_dai_set_fmt function : >> >> https://github.com/torvalds/linux/blob/master/sound/soc/soc-dai.c#L101 >> >> which calls the set_fmt function : >> >> https://github.com/torvalds/linux/blob/master/include/sound/soc-dai.h#L189 >> >> >> >> The snd_soc_dai_ops set_fmt function is defined as : >> >>      int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt); >> >> >> Is there a simple way to find the stream direction from a snd_soc_dai ? >> >> If the stream direction can be detected then the playback and capture >> formats can be set independently for the codec. >> >> It there a different way to set the playback and capture formats for >> the codec independently at runtime, depending on the sample rate ? > > FWIW I remember a discussion in the past on how to deal with > interfaces that may have different clocks sources for capture and > playback (typically with the 6-pin version of I2S/TDM), and the answer > was: use two dais, with one dealing with capture and the other with > playback. > > I would bet this applies for the format as well. If you use a DAI that > can do both directions, then indeed there's no obvious way to specify > that formats or clock ownership could be different between the two > directions. > > It would probably make sense anyway to have a representation with two > dais, e.g. the codec capture dai receives data from somewhere and the > codec playback dai forwards it to another destination. > I think I get it ... This approach would keep extra stream selective functionality out of soc-dai.c. That is probably a good thing for the simplicity of the core. A machine driver could then call snd_soc_dai_set_fmt passing in the correct codec_dai from the codec_dais array for the stream they want to operate on. Matt > My 2 cents > -Pierre