Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp201556pxk; Wed, 2 Sep 2020 19:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQkgPK3eydrdYWGR6GSh6fXl4WIguwYaFzvud044NJg1UtMfJFmCxQra4AAeQx6Ri9c9cf X-Received: by 2002:aa7:cccb:: with SMTP id y11mr782571edt.15.1599099828226; Wed, 02 Sep 2020 19:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599099828; cv=none; d=google.com; s=arc-20160816; b=Px1N15AsI6CruOTf2FNzWiUMEgPA5LpzDB0/RRIhsm8ZGxICB2+nidnHx0929nAipV Nlq0S4cEmLp7bp5lFHZQCURxzMKbJhqRJlIHymePCIqVsLU3q0aKWTGtvbGzivoGFSIg yGxq9KGEMykkgZcdIDIfStT/YxMG7VBu+zgmCLylT5AiVMRD1BJxgY/ypaV8qxrzM42Y vBpIuqe40gg+BO3aTtwhKb879KYLDHy1I0NmLj5pJwm31tiXSdXdZ7BsqR6V/dJzlNwq hcRoNDUlSHCpaRlm1vwV5EoUr8e1RdW1zPeJWixM5NkfGvX40zNejXy8tPo4kbSF1XBv DeGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :dkim-signature; bh=ZHA9Ys3BbFE/uK3mH/P+4binR9tHt/5auQFE5N/VEm0=; b=ivFSez5N8Xscxrwxsl9hJEDBNonAO1/EXq3Sasy3fHNm98pS83eINGu/rmpwMlJyrm 5f7320LNg1jLC2JH2RwbVJupDTEUtj5reDdStbtzZ85WodPGSD2KqT02PcVVSqayOtW7 oUAA1LiPIwfWEUjmGFGPs7DHBQOKC+lOI5beD7HwYi4vokZDyOEFQW3nqRr61s4DNd5I 5EP7n+6lVjT2pX7223Exvxd0frZsGDJ6L5qRpLD3HAxnGl3F6wcFab2NlXQTPncu4Mx1 hCW5YqO1tvVuA5JML+8g5cz7W81SIG8CwdkkfpWMlB0mtGpMrSKztrYIPIZJx+IxN8x6 VicA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=UzcvB9eY; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="kCjx+/FX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si707121edw.437.2020.09.02.19.23.19; Wed, 02 Sep 2020 19:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=UzcvB9eY; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="kCjx+/FX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727037AbgICCWk (ORCPT + 99 others); Wed, 2 Sep 2020 22:22:40 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:56015 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbgICCWi (ORCPT ); Wed, 2 Sep 2020 22:22:38 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id CBCB058012E; Wed, 2 Sep 2020 22:22:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 02 Sep 2020 22:22:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=Z HA9Ys3BbFE/uK3mH/P+4binR9tHt/5auQFE5N/VEm0=; b=UzcvB9eY6ycvjTjhV WwTnXWT54TlevB6RLGw7acGaDmeskyXA5dcl+AXs2KFel9Xu8ZW91OO5gokvoQEb zivH2O4QcO1GkP3YGZTyxpG6U5va3Vd/QfQ2vRlcJhRkfa/UJsu3NeklgonwOB6A Mv+ysNCLiF0DAk2o5Llzz+6iGuR+/qpNXEhKqhmHkFOPRRg71+fqc3TQ5ZFbjA8s R6gXI4JesAytjW0D5W9eodwEuGBN0i3A8BCrtow9yervRe7hP7zHKAHiFWzRjVt+ +8fx0Lu0+4DpBoU3Si7QDdtAwwcjWBtGv6nTvZR6FBDHfJa1NxFAbsXarwUQ7uMR mvhCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ZHA9Ys3BbFE/uK3mH/P+4binR9tHt/5auQFE5N/VE m0=; b=kCjx+/FXNJqGJx61GurAtrQrD3mCorm0S1vRvhGowKWZNZfJ7aM/9TGkT tGAO9nEWiB/TxAGpQ3Xo03Bvd+lVerHFT+R6+uFFTWMEfmC5OVKloqKZb21A8T/4 F/HfDXUDHliLuqZzaXZwghjFKkA20r/cQguj4pqadm8GAalR1X8u5JibrwT5aXsx DmvS2ck7cuiqgLpBUv+8nXe6nQU2mdVvMP6yB32a9oE6NoOKmwF8kIqiPJgnOC+t fml/J4PmjFJBrtq8Mt0EcYdCiVc8r4Iw5vPnZXLMNykFaz4GMwgUA0HgMrexJgh5 08GmtrMeQg3wQnSa4YvMnjFCS2scg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegtddgheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepgfelkeduveejtdejhfeiledvhfeggeeiieeklefhfeefffffffeg udetteelieejnecukfhppeejtddrudefhedrudegkedrudehudenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgr nhgurdhorhhg X-ME-Proxy: Received: from [192.168.50.169] (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 6A1043280063; Wed, 2 Sep 2020 22:22:34 -0400 (EDT) Subject: Re: [linux-sunxi] [PATCH 05/16] ASoc: sun4i-i2s: Add 20 and 24 bit support To: =?UTF-8?Q?Jernej_=c5=a0krabec?= , peron.clem@gmail.com, Maxime Ripard , Chen-Yu Tsai , Mark Brown , Liam Girdwood Cc: Rob Herring , Jaroslav Kysela , Takashi Iwai , Marcus Cooper , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com References: <20200704113902.336911-1-peron.clem@gmail.com> <20200704113902.336911-6-peron.clem@gmail.com> <1e320dfd-9388-54b2-dba9-7def0bf4bbad@sholland.org> <9148679.oVN3Z7rve9@kista> From: Samuel Holland Message-ID: Date: Wed, 2 Sep 2020 21:22:33 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <9148679.oVN3Z7rve9@kista> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/2/20 1:10 PM, Jernej Škrabec wrote: > Hi Samuel! > > Dne petek, 10. julij 2020 ob 07:44:51 CEST je Samuel Holland napisal(a): >> On 7/4/20 6:38 AM, Clément Péron wrote: >>> From: Marcus Cooper >>> >>> Extend the functionality of the driver to include support of 20 and >>> 24 bits per sample. >>> >>> Signed-off-by: Marcus Cooper >>> Signed-off-by: Clément Péron >>> --- >>> >>> sound/soc/sunxi/sun4i-i2s.c | 11 +++++++++-- >>> 1 file changed, 9 insertions(+), 2 deletions(-) >>> >>> diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c >>> index f78167e152ce..bc7f9343bc7a 100644 >>> --- a/sound/soc/sunxi/sun4i-i2s.c >>> +++ b/sound/soc/sunxi/sun4i-i2s.c >>> @@ -577,6 +577,9 @@ static int sun4i_i2s_hw_params(struct >>> snd_pcm_substream *substream,> >>> case 16: >>> width = DMA_SLAVE_BUSWIDTH_2_BYTES; >>> break; >>> >>> + case 32: >>> + width = DMA_SLAVE_BUSWIDTH_4_BYTES; >>> + break; >> >> This breaks the sun4i variants, because sun4i_i2s_get_wss returns 4 for a 32 >> bit width, but it needs to return 3. > > I'm not sure what has WSS with physical width and DMA? This is the change where creating a S24_LE stream no longer fails with -EINVAL. So this is the change where userspace stops downsampling 24-bit audio sources. So this is the change where playback of 24-bit audio sources breaks, because WSS is programmed wrong. >> As a side note, I wonder why we use the physical width (the spacing between >> samples in RAM) to drive the slot width. S24_LE takes up 4 bytes per sample >> in RAM, which we need for DMA. But I don't see why we would want to >> transmit the padding over the wire. I would expect it to be transmitted the >> same as S24_3LE (which has no padding). It did not matter before, because >> the only supported format had no padding. > > Allwinner DMA engines support only 1, 2, 4 and sometimes 8 bytes for bus > width, so if sample is 24 bits in size, we have no other way but to transmit > padding too. I understand why we do 4 byte DMA from RAM <=> I2S FIFO; that was not my question. I'm referring to the actual wire format (FIFO <=> PCM_DIN/DOUT). The sample is already truncated from 32 bits to 24 bits in the FIFO -- that's what TXIM and RXOM in FIFO_CTRL control. If a sample is 24 bits wide, why would we send 32 BCLKs for every LRCK? I would expect the slot width to match the sample resolution by default. But yet we have this code in the driver: unsigned int word_size = params_width(params); unsigned int slot_width = params_physical_width(params); I think slot_width should be the same as word_size, and I suggest changing it before adding 20/24-bit support. > Best regards, > Jernej Regards, Samuel >>> default: >>> dev_err(dai->dev, "Unsupported physical sample width: > %d\n", >>> >>> params_physical_width(params)); >>> >>> @@ -1063,6 +1066,10 @@ static int sun4i_i2s_dai_probe(struct snd_soc_dai >>> *dai)> >>> return 0; >>> >>> } >>> >>> +#define SUN4I_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ >>> + SNDRV_PCM_FMTBIT_S20_LE | \ >>> + SNDRV_PCM_FMTBIT_S24_LE) >>> + >>> >>> static struct snd_soc_dai_driver sun4i_i2s_dai = { >>> >>> .probe = sun4i_i2s_dai_probe, >>> .capture = { >>> >>> @@ -1070,14 +1077,14 @@ static struct snd_soc_dai_driver sun4i_i2s_dai = { >>> >>> .channels_min = 1, >>> .channels_max = 8, >>> .rates = SNDRV_PCM_RATE_8000_192000, >>> >>> - .formats = SNDRV_PCM_FMTBIT_S16_LE, >>> + .formats = SUN4I_FORMATS, >>> >>> }, >>> .playback = { >>> >>> .stream_name = "Playback", >>> .channels_min = 1, >>> .channels_max = 8, >>> .rates = SNDRV_PCM_RATE_8000_192000, >>> >>> - .formats = SNDRV_PCM_FMTBIT_S16_LE, >>> + .formats = SUN4I_FORMATS, >>> >>> }, >>> .ops = &sun4i_i2s_dai_ops, >>> .symmetric_rates = 1, > > > >