Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B861DC433FE for ; Thu, 16 Dec 2021 09:49:59 +0000 (UTC) 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 E810B17D2; Thu, 16 Dec 2021 10:49:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E810B17D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1639648197; bh=0wYl8lEtb0p+l/2quEKfYyCZ3KU7GlC2BhL0UVkQilU=; h=Subject:To:References:From:Date:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZiM+8kv1G0AXsmavQPTMjm6QLQfxwvO0ZRFJwXxeVZ03UaWi3/wwxbAId0fTaB0aE kia4YnIqAQdt/b3FyicAYGJAA3p7ZZGsjgdqRqBnVrhWn20cRsqbRYQVYIDMPvMCSc ugnGMj+6Zurm+sNHprwLJgr+41ihSvvPxVlivAvM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 72495F800DE; Thu, 16 Dec 2021 10:49:06 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1154DF8014C; Thu, 16 Dec 2021 10:49:05 +0100 (CET) Received: from www381.your-server.de (www381.your-server.de [78.46.137.84]) (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 E6BDEF800DE for ; Thu, 16 Dec 2021 10:49:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E6BDEF800DE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="GOAmdyeS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=ntg7e5pIKDJub3AsWnxe963Ibt7J4lRU+KrHr8W7tG8=; b=GOAmdyeSR7QsSfG3ra+8yb3rYk EONX1kgKi2wk1EO68BZU3uxZn92JsqP0zfe3/P8Mfyzzp41D44lv9dUBI0bKp3DEe+JrAUYtbIhAn ejRS3y2UTHbOyxgOfczuIEVOz0hOlVfmOpJG0XyiOl/+ztuxQavSFEmVT6QB+/lzyMmBQ3WVXGbVh ldjUav1Ienph+0nvf8JL+qHTFmGFOaYZD14LkyiabLYRL/yflL8X4j2xq4PG2KoQj7eFOoLLmBqqw tl4aP3DdQUwIQC8114/r7F86KncHNhYDUgPoH++X8V4dtDyidUl5DKauM75ABDSKgluReXxdxni4Q /eFkomRA==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mxnNh-000Dab-6X; Thu, 16 Dec 2021 10:48:57 +0100 Received: from [2001:a61:2bc8:8501:9e5c:8eff:fe01:8578] by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxnNh-000WCD-21; Thu, 16 Dec 2021 10:48:57 +0100 Subject: Re: Question about soc_pcm_apply_msb() To: Kuninori Morimoto , Mark Brown References: <871r2dnir2.wl-kuninori.morimoto.gx@renesas.com> From: Lars-Peter Clausen Message-ID: <638df4d7-0645-1cf7-635a-ea448d0c3aef@metafoo.de> Date: Thu, 16 Dec 2021 10:48:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <871r2dnir2.wl-kuninori.morimoto.gx@renesas.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.103.3/26389/Thu Dec 16 07:02:49 2021) Cc: Linux-ALSA , Kuninori Morimoto 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 12/16/21 7:53 AM, Kuninori Morimoto wrote: > Hi ALSA ML > > At soc_pcm_apply_msb(), > (A) part finds max sig_bits for Codec, and > (B) part finds max sig_bits for CPU > and, set it to substream via soc_pcm_set_msb() at (X), (Y). > > static void soc_pcm_apply_msb() > { > ... > ^ for_each_rtd_codec_dais(rtd, i, codec_dai) { > (A) ... > v bits = max(pcm_codec->sig_bits, bits); > } > > ^ for_each_rtd_cpu_dais(rtd, i, cpu_dai) { > (B) ... > v cpu_bits = max(pcm_cpu->sig_bits, cpu_bits); > } > > (X) soc_pcm_set_msb(substream, bits); > (Y) soc_pcm_set_msb(substream, cpu_bits); > } > > I wonder do we need both (X) (Y) ? > I think we can merge (A) and (B) (= find Codec/CPU max sig_bits), > and call soc_pcm_set_msb() once, but am I misunderstand ? We need both. Or alternatively you could write soc_pcm_set_msb(substream, min(bits, cpu_bits)). What this does is it computes the maximum msb bits from both the CPU side and the CODEC side and then sets the msb bits reported to userspace to the minimum of the two. The largest number of MSBs we'll see on the CODEC side is the max() and the largest number of MSBs we'll see on the CPU side is the max(). And the number of MSBs that the application will be able to see is the smaller of the two.