From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 19F1FC433EF for ; Mon, 6 Dec 2021 10:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-reply-to: Date:Subject:Cc:To:From:References:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d//sQndC4D8ztwyn12MamKEw5QOp+c2Xh+Y4vUhofZ8=; b=gUZD5TWZsjEeA4 UFHMytr04OtFkc4xk7J2Wqlftln0tW8Epqb3PYc+lLp39v/7AA3MlN1YM61yUfZg0hmnTvpaxwzsh KfX287tqKV/9DNBbvMftDT04tL+NV+4uWdOc+vA6Wp8qhYMcQn9/Oy6QOTJ9VYo/WN5WcLrpSFVB9 59Q6JFZoS5e9z/oZJDWOmCrVeFC/v+HaGPLFuvoOigb+O1D6v3ZuHXxAw6RLLXshD9jc6YoHLtEkB 37KTqJpR/HCa3crN8EimJXiqKajfST2JQNfdyRI17owKmWc11KmKseI62mxSpVLcfC3/Md3u8E2Yg /7wC+i/zoRv7fwxNsZFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muAq7-003G0K-Be; Mon, 06 Dec 2021 10:03:19 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muApo-003Fs8-2O for linux-arm-kernel@lists.infradead.org; Mon, 06 Dec 2021 10:03:04 +0000 Received: by mail-wm1-x336.google.com with SMTP id r9-20020a7bc089000000b00332f4abf43fso7832174wmh.0 for ; Mon, 06 Dec 2021 02:02:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version; bh=EwRufzCkL9m3IObuRmZqykjV86a7hGWtyM9bMzT3rvA=; b=ES8wHdihRhnjRJos4Z/tDeIEjiR5kMVsaAuYNps2766HZYtyaiwZAMwMIEJTUsG5cD ue75eGjnGiufCHqPNFD2XXeCsoAkiBgdS32RKWIkWUwNvJ+/Xr5inysiTWbtOkK3lqm2 GOK7DNwfwhB5VxgGuRXXDC+brk7OqBLi2o34QeXDWw87dl8LoDwmPYQsUw+pCKjNl1qu kaoCWtvgvGtl1jK4/L9I+4ExuYFjWAZ9RI4xC5JXSSDXadyrK5JZZKj9YVOxyi7ZqBGg 4miTMxqZs8aI0wGib2Sbc9l8h/wukqCkZNIW2hG5hzLCpHo0TpY8cGTrljDXEuaXq90o XN3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version; bh=EwRufzCkL9m3IObuRmZqykjV86a7hGWtyM9bMzT3rvA=; b=rlWyfErR2dhR0DMICOUDa/DFjsmdoQaSE4DGvJsHnVQnd5Cw9tMM/rtpxpjsySTTTo lOX9A2ekFnY+Iv0gn7SwlWrGzTGZTbDSnz4ehlhI3haEUHvznzxAFAAoRbZI/XkGF9Ne qeQRcG95nZS+JoXLymHnt9SkRA+yZDpndCwTaDNW4haaAtOtOjvUaecoIAGNbpSinVN6 P52UdQe5RKXE3M22DjqKlvbetDezic9rrsW0fNZL7aFYiGxrkMGnBBmSvZKxKHIPMWFX 2f+lRV7DYUCmuWD9o1g+XuFAKv/ryDcvu2Oa+3snu15PpifS6VKp7EcYABPID00z0J6p rv/Q== X-Gm-Message-State: AOAM531qfg1ORCKQJe8PC0fNRS2cXOfcQJXMyfHqgek9pzQjnfy7Fc9D TTdVS7GpvtlR29xBmGQJ9ofL4Q== X-Google-Smtp-Source: ABdhPJyURKFQsrvAfs7KZPb2/UzHqWFRqkiP8mA5+YJrcWw8UrelaZtMVRmjB+okG8CcJKxS0nho5w== X-Received: by 2002:a1c:ed18:: with SMTP id l24mr39249182wmh.99.1638784978119; Mon, 06 Dec 2021 02:02:58 -0800 (PST) Received: from localhost (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id n14sm8423719wrf.69.2021.12.06.02.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 02:02:57 -0800 (PST) References: <20211205180816.2083864-1-martin.blumenstingl@googlemail.com> <20211205180816.2083864-3-martin.blumenstingl@googlemail.com> User-agent: mu4e 1.6.10; emacs 27.1 From: Jerome Brunet To: Martin Blumenstingl , linux-amlogic@lists.infradead.org, alsa-devel@alsa-project.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Christian Hewitt , Geraldo Nascimento Subject: Re: [PATCH RFC v1 2/2] ASoC: meson: aiu: Move AIU_I2S_MISC hold setting to aiu-fifo-i2s Date: Mon, 06 Dec 2021 10:54:19 +0100 In-reply-to: <20211205180816.2083864-3-martin.blumenstingl@googlemail.com> Message-ID: <1jfsr659v1.fsf@starbuckisacylon.baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211206_020300_246930_44E8D26C X-CRM114-Status: GOOD ( 29.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun 05 Dec 2021 at 19:08, Martin Blumenstingl wrote: > The out-of-tree vendor driver uses the following approach to set the > AIU_I2S_MISC register: > 1) write AIU_MEM_I2S_START_PTR and AIU_MEM_I2S_RD_PTR > 2) configure AIU_I2S_MUTE_SWAP[15:0] > 3) write AIU_MEM_I2S_END_PTR > 4) set AIU_I2S_MISC[2] to 1 (documented as: "put I2S interface in hold > mode") > 5) set AIU_I2S_MISC[4] to 1 (depending on the driver revision it always > stays at 1 while for older drivers this bit is unset in step 4) > 6) set AIU_I2S_MISC[2] to 0 > 7) write AIU_MEM_I2S_MASKS > 8) toggle AIU_MEM_I2S_CONTROL[0] > 9) toggle AIU_MEM_I2S_BUF_CNTL[0] > > Additional testing shows that when AIU_I2S_MISC[2] is set to 1 then no > interrupts are generated anymore. The way this bit is managed by the > vendor driver as well as not getting any interrupts can mean that it's > related to the FIFO and not the encoder. Not necessarily. If the encoder stops pulling data, the FIFO will going over the DDR. Since it generates an IRQ after reading N bytes, IRQ would stop too. AFAIK, if the pipeline is stalled, the IRQ stops anyway ... but this is not really important > > Move setting the AIU_I2S_MISC[2] bit to aiu_fifo_i2s_hw_params() so it > closer resembles the flow in the vendor kernel. While here also > configure AIU_I2S_MISC[4] (documented as: "force each audio data to > left or right according to the bit attached with the audio data") > similar to how the vendor driver does this. I understand the part of HOLD, not about FORCE_LR. Is it necessary to fix the problem ? Have you tested without this change ? > This fixes the infamous and > long-standing "machine gun noise" issue (a buffer underrun issue). Well done ! It took us a while to nail it, Thanks a lot !! > > Fixes: 6ae9ca9ce986bf ("ASoC: meson: aiu: add i2s and spdif support") > Reported-by: Christian Hewitt > Reported-by: Geraldo Nascimento > Signed-off-by: Martin Blumenstingl > --- > sound/soc/meson/aiu-encoder-i2s.c | 33 ------------------------------- > sound/soc/meson/aiu-fifo-i2s.c | 12 +++++++++++ > 2 files changed, 12 insertions(+), 33 deletions(-) > > diff --git a/sound/soc/meson/aiu-encoder-i2s.c b/sound/soc/meson/aiu-encoder-i2s.c > index 932224552146..67729de41a73 100644 > --- a/sound/soc/meson/aiu-encoder-i2s.c > +++ b/sound/soc/meson/aiu-encoder-i2s.c > @@ -18,7 +18,6 @@ > #define AIU_RST_SOFT_I2S_FAST BIT(0) > > #define AIU_I2S_DAC_CFG_MSB_FIRST BIT(2) > -#define AIU_I2S_MISC_HOLD_EN BIT(2) > #define AIU_CLK_CTRL_I2S_DIV_EN BIT(0) > #define AIU_CLK_CTRL_I2S_DIV GENMASK(3, 2) > #define AIU_CLK_CTRL_AOCLK_INVERT BIT(6) > @@ -36,37 +35,6 @@ static void aiu_encoder_i2s_divider_enable(struct snd_soc_component *component, > enable ? AIU_CLK_CTRL_I2S_DIV_EN : 0); > } > > -static void aiu_encoder_i2s_hold(struct snd_soc_component *component, > - bool enable) > -{ > - snd_soc_component_update_bits(component, AIU_I2S_MISC, > - AIU_I2S_MISC_HOLD_EN, > - enable ? AIU_I2S_MISC_HOLD_EN : 0); > -} > - > -static int aiu_encoder_i2s_trigger(struct snd_pcm_substream *substream, int cmd, > - struct snd_soc_dai *dai) > -{ > - struct snd_soc_component *component = dai->component; > - > - switch (cmd) { > - case SNDRV_PCM_TRIGGER_START: > - case SNDRV_PCM_TRIGGER_RESUME: > - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: > - aiu_encoder_i2s_hold(component, false); > - return 0; > - > - case SNDRV_PCM_TRIGGER_STOP: > - case SNDRV_PCM_TRIGGER_SUSPEND: > - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > - aiu_encoder_i2s_hold(component, true); > - return 0; > - > - default: > - return -EINVAL; > - } > -} > - > static int aiu_encoder_i2s_setup_desc(struct snd_soc_component *component, > struct snd_pcm_hw_params *params) > { > @@ -353,7 +321,6 @@ static void aiu_encoder_i2s_shutdown(struct snd_pcm_substream *substream, > } > > const struct snd_soc_dai_ops aiu_encoder_i2s_dai_ops = { > - .trigger = aiu_encoder_i2s_trigger, > .hw_params = aiu_encoder_i2s_hw_params, > .hw_free = aiu_encoder_i2s_hw_free, > .set_fmt = aiu_encoder_i2s_set_fmt, > diff --git a/sound/soc/meson/aiu-fifo-i2s.c b/sound/soc/meson/aiu-fifo-i2s.c > index 2388a2d0b3a6..d0a1090d6465 100644 > --- a/sound/soc/meson/aiu-fifo-i2s.c > +++ b/sound/soc/meson/aiu-fifo-i2s.c > @@ -20,6 +20,8 @@ > #define AIU_MEM_I2S_CONTROL_MODE_16BIT BIT(6) > #define AIU_MEM_I2S_BUF_CNTL_INIT BIT(0) > #define AIU_RST_SOFT_I2S_FAST BIT(0) > +#define AIU_I2S_MISC_HOLD_EN BIT(2) > +#define AIU_I2S_MISC_FORCE_LEFT_RIGHT BIT(4) > > #define AIU_FIFO_I2S_BLOCK 256 > > @@ -90,6 +92,10 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream, > unsigned int val; > int ret; > > + snd_soc_component_update_bits(component, AIU_I2S_MISC, > + AIU_I2S_MISC_HOLD_EN, > + AIU_I2S_MISC_HOLD_EN); > + > ret = aiu_fifo_hw_params(substream, params, dai); > if (ret) > return ret; > @@ -117,6 +123,12 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream, > snd_soc_component_update_bits(component, AIU_MEM_I2S_MASKS, > AIU_MEM_I2S_MASKS_IRQ_BLOCK, val); > > + snd_soc_component_update_bits(component, AIU_I2S_MISC, > + AIU_I2S_MISC_FORCE_LEFT_RIGHT, > + AIU_I2S_MISC_FORCE_LEFT_RIGHT); If it is necessary, even if we don't really understand why, it is fine by me. But if it is not, I would prefer we leave it out of it, or at least, make it a separate patch. > + snd_soc_component_update_bits(component, AIU_I2S_MISC, > + AIU_I2S_MISC_HOLD_EN, 0); > + > return 0; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel