From patchwork Thu Feb 13 03:27:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11379731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1CBE924 for ; Thu, 13 Feb 2020 03:29:02 +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 BF13B20724 for ; Thu, 13 Feb 2020 03:29:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="AP9mH3cg"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ooBiGRaH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF13B20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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 B68BF83B; Thu, 13 Feb 2020 04:28:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B68BF83B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1581564539; bh=EkMdrRRynsNeRe/Trho5i7omMZ6ouGb66zX60j0idik=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AP9mH3cgROGjL9+KvjFt27s74s1cR92tkoMtk/euMfUscCaiQCtNvDpqTEXz1JNzI SU2MMekRPWUaN2wPPXIbNjGknaK0B23lxmaCK8ThQ+R60tmSr/khnwqSRbNOs5TPn+ 9EeU9wMaKRYMVXcwTjS9ItK4h56lwM5bbamW3s+U= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0F2DAF80145; Thu, 13 Feb 2020 04:28:16 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 43061F80146; Thu, 13 Feb 2020 04:28:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=disabled version=3.4.0 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 30FC4F80139 for ; Thu, 13 Feb 2020 04:28:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 30FC4F80139 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ooBiGRaH" Received: by mail-yb1-xb49.google.com with SMTP id t186so3885184yba.23 for ; Wed, 12 Feb 2020 19:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=9L2d+CO6Iyos1YOInxK92sjPkbyLs9BRcpmHv2LXX8g=; b=ooBiGRaHF0lQpMx3NrkyYso9Vg9U9LYDN3KdVrDMARpGk8sb5+gaD0qtEjj+1hoWuC /ivpNqekvXwf87djXaeyJMNhC6rCJR8PUhEIaynnsvNyAM/67L6ykF4a80A/52PXtdiz ruAf9sKaytmBdcjOnsWh1UkIAy7GM9rU4PBjo2MwOgFS4MRxUUqzukAXo8k0tWBYmYDz jOXDmliG+BqbURX+CA2jfYVQfPEUI26OzdN3Gy5fMJokl3zVw1em3KRUpLMWrUjla6OT pkjzBSyN5pytS6B0cWmlGweUWC4EIm3TLxlCm2pFAvrJDshQLqudH6I+VFEBlh2OYYNN 4GiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=9L2d+CO6Iyos1YOInxK92sjPkbyLs9BRcpmHv2LXX8g=; b=XrpG++1IgHfJuz2QBgTCznfMqv2wrIQM/BeIAUPYU3l1u/ToEVNCAhdA5kJVs2R4RV 8lZhEm2BEykPUbs/MK1LapJKdH4n30r1Fbw7DHW7ihfdV8BrGt9PGHCLpMoxpJ9ys5QW L2qtCKW5ZN4LSaMrTHvIMlm04M0jsRDnI+lhpHiQPegQ9xXe77NboiXzZNohc45h8spi Th7FkZSK/280eu4CgZLGNgY6sxl4tM6RAJ5yEDM54uaOcVfkYOmFIJELaNWCL+yATfc+ hppW9p64C8awpjD7sxuFwLpnLkR49hcgtIrW+eJgjMeh5BEXbUk1QsOAoegDoyH7U0tK jc+g== X-Gm-Message-State: APjAAAXNJfRyFmYQpdA1KIbT+6ewqGEaQyepB7q+yJEsjDw/JCtonhSS qb1bQgfogH29mdCWwaUr+TYTuaoPeDjk X-Google-Smtp-Source: APXvYqwbp+7cxC8s8vtORhN0Sl2jZxLQ/2oHq4Pp/mPNcssexkboT1Z7BmlUYSSQ47XnPVS7LDiLc6KIBBH4 X-Received: by 2002:a81:50d6:: with SMTP id e205mr11985558ywb.208.1581564486940; Wed, 12 Feb 2020 19:28:06 -0800 (PST) Date: Thu, 13 Feb 2020 11:27:25 +0800 In-Reply-To: <20200213032728.199462-1-tzungbi@google.com> Message-Id: <20200213112003.1.Ie5aedb9d34ebfc7f05ceb382bfe346c45331cd63@changeid> Mime-Version: 1.0 References: <20200213032728.199462-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.225.g125e21ebc7-goog From: Tzung-Bi Shih To: broonie@kernel.org Cc: tzungbi@google.com, alsa-devel@alsa-project.org, dgreid@google.com, cychiang@google.com Subject: [alsa-devel] [RESEND PATCH 1/4] ASoC: mediatek: mt8183-da7219: change supported formats of DL2 and UL1 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" DL2 and UL1 are for BTSCO. Provides only 16-bit, mono, 8kHz and 16kHz to userspace. Signed-off-by: Tzung-Bi Shih --- .../mediatek/mt8183/mt8183-da7219-max98357.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c index 1626541cc0d6..b52ffed882a7 100644 --- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c @@ -116,6 +116,46 @@ static int mt8183_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } +static int +mt8183_da7219_max98357_bt_sco_startup( + struct snd_pcm_substream *substream) +{ + static const unsigned int rates[] = { + 8000, 16000 + }; + static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, + }; + static const unsigned int channels[] = { + 1, + }; + static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, + }; + + struct snd_pcm_runtime *runtime = substream->runtime; + + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + runtime->hw.channels_max = 1; + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + + runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; + snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); + + return 0; +} + +static const struct snd_soc_ops mt8183_da7219_max98357_bt_sco_ops = { + .startup = mt8183_da7219_max98357_bt_sco_startup, +}; + /* FE */ SND_SOC_DAILINK_DEFS(playback1, DAILINK_COMP_ARRAY(COMP_CPU("DL1")), @@ -222,6 +262,7 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, .dpcm_playback = 1, + .ops = &mt8183_da7219_max98357_bt_sco_ops, SND_SOC_DAILINK_REG(playback2), }, { @@ -240,6 +281,7 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, .dpcm_capture = 1, + .ops = &mt8183_da7219_max98357_bt_sco_ops, SND_SOC_DAILINK_REG(capture1), }, { From patchwork Thu Feb 13 03:27:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11379735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 779D41395 for ; Thu, 13 Feb 2020 03:30:46 +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 0A88620724 for ; Thu, 13 Feb 2020 03:30:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="n1Bq++ZI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="X2c70U7z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A88620724 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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 5E477168F; Thu, 13 Feb 2020 04:30:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5E477168F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1581564644; bh=6f5PtrIK8zZP0uFArOKQJhlQWmnlDuizLab8oV/RXPc=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n1Bq++ZI5z9OcDjD4GC3r0csBnCJKm1QWoyRjN4gmG+ggdvf3p69kb295BPKPdCZ7 5naL7caDOOTUdAehp+5Lb+R0MurXQbK+JwbiF8xthJvGInfkvmT+asGQ7Jjl+6W6LK ppC12y0GcphELhjNHH3VdyyHkAXvN2Cw3qpib/N4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2AC36F8027B; Thu, 13 Feb 2020 04:28:22 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2351EF80218; Thu, 13 Feb 2020 04:28:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=disabled version=3.4.0 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 56B83F80139 for ; Thu, 13 Feb 2020 04:28:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 56B83F80139 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="X2c70U7z" Received: by mail-qk1-x749.google.com with SMTP id c206so2841804qkg.6 for ; Wed, 12 Feb 2020 19:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=E8XGL+aWSCUS5wxSR4Mb7Xw8cB7NMNQcId090CzAdf0=; b=X2c70U7zuMgkw/dU9EktkpTjUexjIWBqK63Dkafrpd0LziWsamJbiSG5SSY2MX7fsc CkA46/edzwGlg6p+xNpyTa5DgwDZJ/kkbyxBCPbaqJBDLDfFibBQjOJJGmCKTxbL1itk IMjNJ0Bp7zINvc+B0z54oYR5aCWTFn/BWeRm4S1Y6PrXQunzWZIzXhv0KZ+Is6jBz/Cw qGoDS0c30pVNUV7pbV67Ks5AV+gj5ArbFLS8g3fTQQwuxMDsTEWve5OQUUG+U3Nh5xG7 qLTbCyAZkB4jBWROgoujRGEbrpixyxs6jI4xaEE1BlTpvawyq/Id0pv0tfEZhRBxcI0l SwMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=E8XGL+aWSCUS5wxSR4Mb7Xw8cB7NMNQcId090CzAdf0=; b=ssiNDQK86wommvBF93XTVUtOOjWNhsZT84VMOSeB4ze5VN8K4WXpTBlqn2m2C2Hg0D GK5WK2IeWode5JLubqVnl/arUs2HZcwrqXR1CS+dkZBmISVfrs7pA+R5Q8G4fG/9BoEh oUtASO97lWefyEpBUhxyOV/htkQKJJycbnbZbE2OdMtWLzq74b3f6I46u499UTb048kH z77UbsdU3YYrQDO+hrHeE9qdZdZBlsLmZEJjg+0/qWebaCLMYxXbigLskew7OYFN4+9c uitugjH9aLVauxivVAzOBnMzKb0qBCWWXfvdj8ygJ4vqZU1xB7fZnP+jF9L2mW1MfjnW OSAw== X-Gm-Message-State: APjAAAW9ghot5VEogrWVagNuaoGZXDH+SJpt1mgGNGxyxumytdY0CSB7 qh76xTTPuOM75TYAeI/pn6j8W+wEwPom X-Google-Smtp-Source: APXvYqwDK9WTwkNNGulURpe49iGFFYSxfkeDdVr+CG0UVvGpr4fPcdoRHAY9eCUBlAygyGxpcK3+z+71mF+7 X-Received: by 2002:a0c:f193:: with SMTP id m19mr9563746qvl.154.1581564491960; Wed, 12 Feb 2020 19:28:11 -0800 (PST) Date: Thu, 13 Feb 2020 11:27:26 +0800 In-Reply-To: <20200213032728.199462-1-tzungbi@google.com> Message-Id: <20200213112003.2.I1d568b0c99742c6e755d051aadfd52e4be3cc0a5@changeid> Mime-Version: 1.0 References: <20200213032728.199462-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.225.g125e21ebc7-goog From: Tzung-Bi Shih To: broonie@kernel.org Cc: tzungbi@google.com, alsa-devel@alsa-project.org, dgreid@google.com, cychiang@google.com Subject: [alsa-devel] [RESEND PATCH 2/4] ASoC: mediatek: mt8183-da7219: pull TDM GPIO pins down when probed 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" 1. Switch TDM GPIO pins according to playback on or off. 2. Pull TDM GPIO pins down when probed to avoid current leakage. Signed-off-by: Tzung-Bi Shih --- .../mediatek/mt8183/mt8183-da7219-max98357.c | 104 +++++++++++++++++- 1 file changed, 98 insertions(+), 6 deletions(-) diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c index b52ffed882a7..d7685916a5cb 100644 --- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c @@ -18,6 +18,22 @@ static struct snd_soc_jack headset_jack; +enum PINCTRL_PIN_STATE { + PIN_STATE_DEFAULT = 0, + PIN_TDM_OUT_ON, + PIN_TDM_OUT_OFF, + PIN_STATE_MAX +}; + +static const char * const mt8183_pin_str[PIN_STATE_MAX] = { + "default", "aud_tdm_out_on", "aud_tdm_out_off", +}; + +struct mt8183_da7219_max98357_priv { + struct pinctrl *pinctrl; + struct pinctrl_state *pin_states[PIN_STATE_MAX]; +}; + static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -244,6 +260,47 @@ SND_SOC_DAILINK_DEFS(tdm, DAILINK_COMP_ARRAY(COMP_DUMMY()), DAILINK_COMP_ARRAY(COMP_EMPTY())); +static int mt8183_da7219_tdm_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct mt8183_da7219_max98357_priv *priv = + snd_soc_card_get_drvdata(rtd->card); + int ret; + + if (IS_ERR(priv->pin_states[PIN_TDM_OUT_ON])) + return PTR_ERR(priv->pin_states[PIN_TDM_OUT_ON]); + + ret = pinctrl_select_state(priv->pinctrl, + priv->pin_states[PIN_TDM_OUT_ON]); + if (ret) + dev_err(rtd->card->dev, "%s failed to select state %d\n", + __func__, ret); + + return ret; +} + +static void mt8183_da7219_tdm_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct mt8183_da7219_max98357_priv *priv = + snd_soc_card_get_drvdata(rtd->card); + int ret; + + if (IS_ERR(priv->pin_states[PIN_TDM_OUT_OFF])) + return; + + ret = pinctrl_select_state(priv->pinctrl, + priv->pin_states[PIN_TDM_OUT_OFF]); + if (ret) + dev_err(rtd->card->dev, "%s failed to select state %d\n", + __func__, ret); +} + +static struct snd_soc_ops mt8183_da7219_tdm_ops = { + .startup = mt8183_da7219_tdm_startup, + .shutdown = mt8183_da7219_tdm_shutdown, +}; + static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { /* FE */ { @@ -395,6 +452,8 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { .no_pcm = 1, .dpcm_playback = 1, .ignore_suspend = 1, + .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, + .ops = &mt8183_da7219_tdm_ops, SND_SOC_DAILINK_REG(tdm), }, }; @@ -470,7 +529,7 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) struct snd_soc_card *card = &mt8183_da7219_max98357_card; struct device_node *platform_node; struct snd_soc_dai_link *dai_link; - struct pinctrl *default_pins; + struct mt8183_da7219_max98357_priv *priv; int ret, i; card->dev = &pdev->dev; @@ -504,12 +563,45 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) return ret; } - default_pins = - devm_pinctrl_get_select(&pdev->dev, PINCTRL_STATE_DEFAULT); - if (IS_ERR(default_pins)) { - dev_err(&pdev->dev, "%s set pins failed\n", + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + snd_soc_card_set_drvdata(card, priv); + + priv->pinctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(priv->pinctrl)) { + dev_err(&pdev->dev, "%s devm_pinctrl_get failed\n", __func__); - return PTR_ERR(default_pins); + return PTR_ERR(priv->pinctrl); + } + + for (i = 0; i < PIN_STATE_MAX; i++) { + priv->pin_states[i] = pinctrl_lookup_state(priv->pinctrl, + mt8183_pin_str[i]); + if (IS_ERR(priv->pin_states[i])) { + ret = PTR_ERR(priv->pin_states[i]); + dev_info(&pdev->dev, "%s Can't find pin state %s %d\n", + __func__, mt8183_pin_str[i], ret); + } + } + + if (!IS_ERR(priv->pin_states[PIN_TDM_OUT_OFF])) { + ret = pinctrl_select_state(priv->pinctrl, + priv->pin_states[PIN_TDM_OUT_OFF]); + if (ret) + dev_info(&pdev->dev, + "%s failed to select state %d\n", + __func__, ret); + } + + if (!IS_ERR(priv->pin_states[PIN_STATE_DEFAULT])) { + ret = pinctrl_select_state(priv->pinctrl, + priv->pin_states[PIN_STATE_DEFAULT]); + if (ret) + dev_info(&pdev->dev, + "%s failed to select state %d\n", + __func__, ret); } return ret; From patchwork Thu Feb 13 03:27:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11379737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B16A5924 for ; Thu, 13 Feb 2020 03:31:26 +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 4757620724 for ; Thu, 13 Feb 2020 03:31:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="L5lKZrbh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="gUuOElcv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4757620724 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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 7954B1678; Thu, 13 Feb 2020 04:30:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7954B1678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1581564684; bh=DRvUtm41KEzUO5dUhHC6n5wpXcZyb24E/Aho6VnFhno=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=L5lKZrbh8xE2ABvkdi5Fqlem0q0aEL3Gv+R3DVGA+kQTiU7TYaso/8aeK9iVZcGQh JHUhjXMTb3JeF1MiAxI9KxxQZj6vg5GUCFNh+nt5goGZMqgJ5GnCTTK0a2k3lhoVVX uOqW7Q99OpGAIzF8bxxaIjrVnG4xzuVAcyogwz4A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 32C9BF8028B; Thu, 13 Feb 2020 04:28:23 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 61290F8027C; Thu, 13 Feb 2020 04:28:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=disabled version=3.4.0 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A30C3F80277 for ; Thu, 13 Feb 2020 04:28:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A30C3F80277 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gUuOElcv" Received: by mail-qv1-xf49.google.com with SMTP id dc2so2709850qvb.7 for ; Wed, 12 Feb 2020 19:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=YxsrroHX4WoK4wnjRbsIka200MhuwAMMClHApCYNJxE=; b=gUuOElcvztb9kTje3Rw1qFDOUqEzakzHnVMuteO/kv52iO5jYQ99NPKND6mdDLeVdT bnLx/wftoHIgQ6UcRRN+zMjePm/cD+3fpTDdRGdTXgObzGumUbxWu077UKu8PR1XZ/5p rAik3YnWo1/3ZabL+X18AMA3q352FrQ/ashqVfZxLdnG2IWMDhtDULX6gu324LRQvP1m oLt8LZC5CtxX/sY2gCUqmywjPi7jpoDUes99XjSxyzE17BQBY/GNQSddFJRRltRO4UZr i1JaZE/gNu3PtF5d43Tx1x9UKGe7+iCNe4awuQqJYafkr4Sv5/HeXG+U5J3YZMTXnIyj UKuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=YxsrroHX4WoK4wnjRbsIka200MhuwAMMClHApCYNJxE=; b=XTZvRrgfpvJpn7Z3LDCPT5I1ALYqAsTjTN30OFjdVzm8D2/GbwvjsaP4bCFmnTI1bs ygZCvpJMni0OxJCJoBj6nihSI87r+FzaMa93Xii9AvLQxHcfVTADZXW6ACpXCfWDxhw7 C5DFNTukYFIvjtR5CmjmFjktTnTK2rUjObkYeysdeuEeNjtmIRdGRVMa81kmOasUwlEh Dj+Ro8FS+LaWcgO/EIeroiTH1t4SK0Qb8epQ7d/HgOivU0sER8fXH4sJanxHv188WbiT wqpxqK82lkia13heUT1Dp7e1gH0pEZx0oG9ZXKPZmJCEcdGjDHihf39XnvhDMI9gj4XY i4zw== X-Gm-Message-State: APjAAAUNztWhFnhkiPI13jRazooOqm1PCXK7s9XqNAT4Synwm9QhhhlV 5hOgRNFcna0aTv1UdEGgt3w+1bzsd1Yq X-Google-Smtp-Source: APXvYqxknSwIuerIB61258ruOVURiB1Wnobfw7Of9qCIh4Ju3j1F+iRefyXQE35FWNQ+oByiGivoy2sys+pt X-Received: by 2002:ac8:16ca:: with SMTP id y10mr10383973qtk.340.1581564496925; Wed, 12 Feb 2020 19:28:16 -0800 (PST) Date: Thu, 13 Feb 2020 11:27:27 +0800 In-Reply-To: <20200213032728.199462-1-tzungbi@google.com> Message-Id: <20200213112003.3.I30f0b8c87d5ec2a0e5f1b0fabf0a8ccef374f5ea@changeid> Mime-Version: 1.0 References: <20200213032728.199462-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.225.g125e21ebc7-goog From: Tzung-Bi Shih To: broonie@kernel.org Cc: tzungbi@google.com, alsa-devel@alsa-project.org, dgreid@google.com, cychiang@google.com Subject: [alsa-devel] [RESEND PATCH 3/4] ASoC: mediatek: mt8183-da7219: support TDM out and 8ch I2S out 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" Supports TDM out and 8ch I2S out. Signed-off-by: Tzung-Bi Shih --- sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c index d7685916a5cb..c7f766f24e44 100644 --- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c @@ -450,6 +450,9 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { { .name = "TDM", .no_pcm = 1, + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_IB_IF | + SND_SOC_DAIFMT_CBM_CFM, .dpcm_playback = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, From patchwork Thu Feb 13 03:27:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11379739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42AE81395 for ; Thu, 13 Feb 2020 03:31:46 +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 CD4DA21734 for ; Thu, 13 Feb 2020 03:31:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="gok9jORS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="rsbhc4ma" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD4DA21734 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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 2DD1B1671; Thu, 13 Feb 2020 04:31:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2DD1B1671 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1581564704; bh=PQzqpIRSFhea41V39gS4dnVhrK1A6NXsf9n4kV7aRfY=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gok9jORSciKRIKftaSfWvIGJGV6SVQgsvNFEoJOFX+RlwvXNJ7hXhq5w+ENLFmeX1 fCYedAIDOehKKebLi92GQ6rRVTacRN/jIA9N0iOkanNsTwk+nMNLCr4tiMngCBxMkf FbCs6H2hj1u58DV3ZZaXphWDQ4GVyUHAvvexE6Ck= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 347EBF8028F; Thu, 13 Feb 2020 04:28:29 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 69BACF80290; Thu, 13 Feb 2020 04:28:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,SURBL_BLOCKED,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=disabled version=3.4.0 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 90012F8028C for ; Thu, 13 Feb 2020 04:28:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 90012F8028C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rsbhc4ma" Received: by mail-pf1-x449.google.com with SMTP id z26so2822063pfr.9 for ; Wed, 12 Feb 2020 19:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ABP64oLgld5vXEPTFiENx6A7aVpO8Fw6bmZeeUtOJMQ=; b=rsbhc4maH2PcWoKjR/UCQmHYfFZPMQ1dvwvrKAK8pZQJ0uxSn84lOmOYOKJtVzd1MY hEzFVpxy064Xbyr/NlFPQp4z9h25mnXvYCNhoiCQqtk4BSCVwWCXW6r8RB+BtGMQkBuC 51yMYso+hrR9KyuI64UQT7K9klhLAHrIMPTyGb7ks9Q9d4BR62nrz/LUAOpXS+ReMUel CvMGVj96oexr8LCXovUzOHm3zR85NPn4jwi4bxbzTeKYq7axrDfN7J7m2An1EuANtQoV 9JNbtfk4xEAYzd1HZKNjGHvqK+krBA96aw/gBT/3EQ6WGahQc+CAv4D/fpq+bH3hJYwb WazQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ABP64oLgld5vXEPTFiENx6A7aVpO8Fw6bmZeeUtOJMQ=; b=oQXNUfGKx8pz1A/i6tELNTM3a+8q/aCX7uWExg0Ph4Bf/7OfBPu3KTw/XLSkah3Nmw LT9JDE/jOnxrr4Yzju8ezM7OSam4yFn4WFfgyjZLPIA/KCjyqkYi6Hcf3tOy2r7QUY1N aQn7z1ktzICIYsi9l4v9Q6FoWdeYPIg574SYuNp3N1mk0yoj5Oxb1bzX+LfpIulrk3LH O8W8ujRPt5CMbVUvTPG/SS2RoLo5LDfrcpFweVQEb0c9FLBjoLKfuHeEoJYmEivzh1sS BDfKIMt4wtTWHqaX1ypjWi0eR6SFkFZp8KMKMDNOQTXrTGTgiZhV0oXdls1LWSFE7Ucu i0fg== X-Gm-Message-State: APjAAAWs30GRrjjhGvWOz9SFFCNO9ComHoozqI2RS9wqN/orJ1b1Nefw sjgwQoeXQ3YdUJQnGxjHZMY5TzBfOM1W X-Google-Smtp-Source: APXvYqzsGCgPrpc3+wqAhg0Fnms9LI242P/AkkvRuoTZU8Dj7I4nFqgjzRhg38k2s49Rlz0Xx41oDOLbQhr9 X-Received: by 2002:a63:2447:: with SMTP id k68mr5210134pgk.368.1581564501877; Wed, 12 Feb 2020 19:28:21 -0800 (PST) Date: Thu, 13 Feb 2020 11:27:28 +0800 In-Reply-To: <20200213032728.199462-1-tzungbi@google.com> Message-Id: <20200213112003.4.Ia542007f51d3de753a9e0a83135ee074581dbf71@changeid> Mime-Version: 1.0 References: <20200213032728.199462-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.225.g125e21ebc7-goog From: Tzung-Bi Shih To: broonie@kernel.org Cc: tzungbi@google.com, alsa-devel@alsa-project.org, dgreid@google.com, cychiang@google.com Subject: [alsa-devel] [RESEND PATCH 4/4] ASoC: mediatek: mt8183-da7219: apply some refactors 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" 1. Moves headset jack to card-specific storage. 2. Removes trailing blank line. 3. Moves card registration to the end of probe. Signed-off-by: Tzung-Bi Shih --- .../mediatek/mt8183/mt8183-da7219-max98357.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c index c7f766f24e44..c0c85972cfb7 100644 --- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c @@ -16,8 +16,6 @@ #include "../../codecs/da7219-aad.h" #include "../../codecs/da7219.h" -static struct snd_soc_jack headset_jack; - enum PINCTRL_PIN_STATE { PIN_STATE_DEFAULT = 0, PIN_TDM_OUT_ON, @@ -32,6 +30,7 @@ static const char * const mt8183_pin_str[PIN_STATE_MAX] = { struct mt8183_da7219_max98357_priv { struct pinctrl *pinctrl; struct pinctrl_state *pin_states[PIN_STATE_MAX]; + struct snd_soc_jack headset_jack; }; static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream, @@ -510,6 +509,8 @@ static int mt8183_da7219_max98357_headset_init(struct snd_soc_component *component) { int ret; + struct mt8183_da7219_max98357_priv *priv = + snd_soc_card_get_drvdata(component->card); /* Enable Headset and 4 Buttons Jack detection */ ret = snd_soc_card_jack_new(&mt8183_da7219_max98357_card, @@ -517,12 +518,12 @@ mt8183_da7219_max98357_headset_init(struct snd_soc_component *component) SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, - &headset_jack, + &priv->headset_jack, NULL, 0); if (ret) return ret; - da7219_aad_jack_det(component, &headset_jack); + da7219_aad_jack_det(component, &priv->headset_jack); return ret; } @@ -559,13 +560,6 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) return -EINVAL; } - ret = devm_snd_soc_register_card(&pdev->dev, card); - if (ret) { - dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", - __func__, ret); - return ret; - } - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -607,7 +601,7 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev) __func__, ret); } - return ret; + return devm_snd_soc_register_card(&pdev->dev, card); } #ifdef CONFIG_OF @@ -634,4 +628,3 @@ MODULE_DESCRIPTION("MT8183-DA7219-MAX98357 ALSA SoC machine driver"); MODULE_AUTHOR("Shunli Wang "); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("mt8183_da7219_max98357 soc card"); -