From patchwork Tue Dec 13 09:53:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rouven Czerwinski X-Patchwork-Id: 13071881 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 88BA3C4332F for ; Tue, 13 Dec 2022 09:54:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8E2B418D3; Tue, 13 Dec 2022 10:54:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8E2B418D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1670925295; bh=wz2x8sSZP+2ZhM4wXsF5opLSCVBRhkyY4w8KqKoH1Kw=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=OxoETYgh+/vr3OyP5I2XUbFbJqr8E6lhgnSRjMIjk7L6kMRo1cHvH0AgskU9Bvvqc DGRSYFbHSKrS/sROMPQaiDuwvdthHS/h5pnnx0otS9U1kv6QiGG8N3sraz4P2Xy7fh e7yP+eMtH2ZnCX/n9OrvNEAB0/zZJxPeZIeIG4bE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 39765F804ED; Tue, 13 Dec 2022 10:53:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 665C3F804D6; Tue, 13 Dec 2022 10:53:41 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3F0FFF80431 for ; Tue, 13 Dec 2022 10:53:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3F0FFF80431 Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=localhost) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p51yc-0000eF-QL; Tue, 13 Dec 2022 10:53:30 +0100 From: Rouven Czerwinski To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Subject: [PATCH 1/2] ASoC: max98088: fix dai1/2_hw_params access Date: Tue, 13 Dec 2022 10:53:27 +0100 Message-Id: <20221213095328.122309-1-r.czerwinski@pengutronix.de> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: r.czerwinski@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, Marco Felsch , kernel@pengutronix.de, linux-kernel@vger.kernel.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Marco Felsch According the reference manuals [1], [2] updating register 0x14/1c should only be done after #shdn bit is set to 0. [1] https://datasheets.maximintegrated.com/en/ds/MAX98089.pdf [2] https://datasheets.maximintegrated.com/en/ds/MAX98088.pdf Signed-off-by: Marco Felsch --- sound/soc/codecs/max98088.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 405ec16be2b6..7f108e147355 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -977,6 +977,8 @@ static int max98088_dai1_hw_params(struct snd_pcm_substream *substream, rate = params_rate(params); + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); + switch (params_width(params)) { case 16: snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT, @@ -990,8 +992,6 @@ static int max98088_dai1_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); - if (rate_value(rate, ®val)) return -EINVAL; @@ -1047,6 +1047,8 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, rate = params_rate(params); + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); + switch (params_width(params)) { case 16: snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT, @@ -1060,8 +1062,6 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); - if (rate_value(rate, ®val)) return -EINVAL; From patchwork Tue Dec 13 09:53:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rouven Czerwinski X-Patchwork-Id: 13071880 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 C3BDFC4332F for ; Tue, 13 Dec 2022 09:54:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DEAE718BA; Tue, 13 Dec 2022 10:53:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DEAE718BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1670925271; bh=S26bqUHx8Ihsy8S2KeToBHsCBQZTKUuZo+PEwrm0GzQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=fV5Q1wmnCHQVTpvSmEH9uPMe0S4jJJFjqm9MTyY3xBCD1rklNBhqSBHTOp87QZK42 D+hOPXlHOLrUzf3jFigof3xNyAQiftqbn3XDdxxqNDh69fEs9BUF09glOSk1gmHZMu yNpCjN0RwXS1c+JsG28pHEtQtTST/2BWnMuzNbh8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8C238F80431; Tue, 13 Dec 2022 10:53:41 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B465AF804E2; Tue, 13 Dec 2022 10:53:40 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC445F8047D for ; Tue, 13 Dec 2022 10:53:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AC445F8047D Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=localhost) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p51yd-0000ec-M5; Tue, 13 Dec 2022 10:53:31 +0100 From: Rouven Czerwinski To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Subject: [PATCH 2/2] ASoC: max98088: fix initial dai mute state Date: Tue, 13 Dec 2022 10:53:28 +0100 Message-Id: <20221213095328.122309-2-r.czerwinski@pengutronix.de> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221213095328.122309-1-r.czerwinski@pengutronix.de> References: <20221213095328.122309-1-r.czerwinski@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: r.czerwinski@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, Marco Felsch , kernel@pengutronix.de, linux-kernel@vger.kernel.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Marco Felsch According the datasheets [1], [2] the initial value of register 0x2f/0x31 (dai1/dai2) is 0x00 which means that dai is unmuted. So upon the first playback request the register is not touched since it is cached by regmap. But the device output keeps silent. After ending the playback session the mute() callback updates the register. Now the 2nd playback request updates the register again (-> unmute the device) and now we can really hear the output signal. I've checked the register initial value which is '0x00' so the driver is correct. Accroding the above inspections it seems that the hardware does not update the register correctly on power up because the output is muted. To fix that we need to explicit set the mute state. Now the first playback request gets played correctly. [1] https://datasheets.maximintegrated.com/en/ds/MAX98089.pdf [2] https://datasheets.maximintegrated.com/en/ds/MAX98088.pdf Signed-off-by: Marco Felsch --- sound/soc/codecs/max98088.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 7f108e147355..c00d7726ac04 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -1710,6 +1710,11 @@ static int max98088_probe(struct snd_soc_component *component) snd_soc_component_write(component, M98088_REG_1E_DAI2_IOCFG, M98088_S2NORMAL|M98088_SDATA); + snd_soc_component_update_bits(component, M98088_REG_2F_LVL_DAI1_PLAY, + M98088_DAI_MUTE_MASK, M98088_DAI_MUTE); + snd_soc_component_update_bits(component, M98088_REG_31_LVL_DAI2_PLAY, + M98088_DAI_MUTE_MASK, M98088_DAI_MUTE); + max98088_handle_pdata(component); err_access: