From patchwork Mon Feb 3 08:27:15 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: 11362203 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 2AAC614B4 for ; Mon, 3 Feb 2020 08:29:19 +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 B265820658 for ; Mon, 3 Feb 2020 08:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="C3uEVEyo"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="dHmF7fcp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B265820658 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 EF5E4168F; Mon, 3 Feb 2020 09:28:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF5E4168F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1580718557; bh=hfGcwF3hCb6AvpMEAc2GMl5KvVuuGjZZnxRdrz8F2lk=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=C3uEVEyofgdrLkuujumHByiREBvPkuwNQtZt87sC2PdJYBH5wB654/tpGB+UAR9BA NxiA+co865sOEM4+5gAE4TvFpqYrkbOLEZtd1hmX5ZVwVyYWzr08jNZMRUkl/i0dj+ PLfFshzWhnPsr/KcJvEh81EEreDcfUjLMwtBy0dU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AC8E2F80150; Mon, 3 Feb 2020 09:27:42 +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 A8FEAF80233; Mon, 3 Feb 2020 09:27:41 +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-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) (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 B01C0F8014C for ; Mon, 3 Feb 2020 09:27:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B01C0F8014C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dHmF7fcp" Received: by mail-pl1-x649.google.com with SMTP id 71so4299977plb.18 for ; Mon, 03 Feb 2020 00:27:37 -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=nv/gWXMm1LPjD6+In1LaHObzpkMiIoBLQHOZAKjhzFo=; b=dHmF7fcp26TaKEWfqy4GWMSgHDMVu6lP0xdNny1b7CZgldNeXkOvf5w6bNk4yVDynI hz/uJi4LUTbyMBW8vvc5d9ZQEfAnukG0AsM8FXEt2TSV07U9jxwG6sKXH+Xwi+sOazo+ KtC7R7l68Pv4UhE+G9uDMNzpfhs/HgtnAUCD+J8jvuJVY+w1xGWgpZQEyBusrV1FtGr0 5CWDAgjL87EdKTt3vpa3TToMsgP5zAMqGf1hTc+azjqSydE+4KFfLTX2zteZCxXAPVsF nQK/MTzoyQ6C6TVFRhp038P5Fw5I/XmsZmsXQKbWFd9P/aLif2JmZeYdozHV2zcEURWt M4Eg== 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=nv/gWXMm1LPjD6+In1LaHObzpkMiIoBLQHOZAKjhzFo=; b=cP7E/e33WXYtZFpbXgf6+SNTGZJkCCkT3TnHgVKq4Q6bjQRqwYdW8bqqMRthPjGwJ3 UVwvRsNqlI6WhJ7/e+b0Eukzi1aUMaOdUjU7b81J9IcnZpDeDPtmP3h8WIooT8w14rFH qnuJlGcMm2ytOJa+AswPZ87v6KZmkgyc2dqf8n8FCNr2usC/zmNqB7acWgI1lO0wDHXC MZrqTVw8J/azvYlBFZnREwoh5WTYEZkbeNcZ3Thn20l7+wQt6Z38QWysrXGtCJU7Ouuz JTTQRHC4lQEg4kQuq+ADVVv6PgTBLCqLjIRrj6Hd+YXyYX3orqLsYLoj7F/cb00wfG5e 4bbw== X-Gm-Message-State: APjAAAUeb4xoFdfZriL7OQyLRkuSEG+LBuQgjekNe0RAoL5QB9BWKx1l QWieUruD7aFzRgHlRamItCoY3Qoyo5W0 X-Google-Smtp-Source: APXvYqzyHmoXCfgMHVHFR6gT9T8Azz/oAlmKEtSegXV43hookvRACho2AUKsE8tr7Kh9t3HI6jjViWjXp/D1 X-Received: by 2002:a63:1e1d:: with SMTP id e29mr24493750pge.347.1580718454675; Mon, 03 Feb 2020 00:27:34 -0800 (PST) Date: Mon, 3 Feb 2020 16:27:15 +0800 In-Reply-To: <20200203082718.59614-1-tzungbi@google.com> Message-Id: <20200203151250.1.Ie5aedb9d34ebfc7f05ceb382bfe346c45331cd63@changeid> Mime-Version: 1.0 References: <20200203082718.59614-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-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] [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 c65493721e90..b7d4bfd04b37 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 Mon Feb 3 08:27:16 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: 11362207 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 61696138D for ; Mon, 3 Feb 2020 08:30:06 +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 EBCF220658 for ; Mon, 3 Feb 2020 08:30:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="jPTrOBvd"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="XBtVXCyo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBCF220658 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 1DEAC1686; Mon, 3 Feb 2020 09:29:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1DEAC1686 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1580718604; bh=M5+NSyOS47rjE4KriJWo1dm7/DTk4v7KzN5ywkfg8Ig=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jPTrOBvdRii47MDT4dzH/wfuY476X1orQQ/VpRwI9cNgtMp09dV9rW1fAx0NYQwFj WQY0i44EaX6UUOllHQlsfO85b03WmekczgagYlbv2ycvDBZBZ15jrgodEurM+uTOPe tAw9yuj2LONJqnzAZKTR2sxQeZu/tYX0X99F+nBA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D6E63F80274; Mon, 3 Feb 2020 09:27:48 +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 A3560F80274; Mon, 3 Feb 2020 09:27:47 +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-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) (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 B8C2BF80264 for ; Mon, 3 Feb 2020 09:27:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B8C2BF80264 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XBtVXCyo" Received: by mail-pj1-x104a.google.com with SMTP id d22so7770528pjz.0 for ; Mon, 03 Feb 2020 00:27:42 -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=jRE5YctnhREGEzvzaz37kAkC6vHVXD4/7D5M3YqRd04=; b=XBtVXCyozSDljvzVOsnnk2jbQGsOD8dOpItbjzAeuiUS5eDU+yX3WnmCd+W6CTxD32 3+ib0tdeRJzHZkCQY4GzzV7beh0vzuP+jn7Gme+MZ/5NoBRHwxBvV49TMtplFEmqfFdu 8DCAWccyqcOQ1IBBSz0CohNaLdF3IezC4c5XInyeRtu8FUdQAUoMwte3/v+gKRLgDJZN Jn5YSqYKQI8rH7FOawK+4+/ULe8t34hWnC4lW2bhEb/c9c0hVTxrF4PUcJi5Ncn7XT9i lGi+JezWaR8Feo/T8WuA7Mv0ekaSlK7nxy7gaxiO+8z9KLmuN7BvoiX7Tjqz4to8UI5f /kBw== 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=jRE5YctnhREGEzvzaz37kAkC6vHVXD4/7D5M3YqRd04=; b=HZT6Pq4gS1BIEG9VQW+XiAoVwE+gEHmcr4f1KJSdpbFY/jJT28IYX4bBDhYVHNegpJ OfWWIkIXxeht3WevUNilbLWCemfzD4b2CtOe/WV6WKBCvBS11J1JXUEL/VKQHHgQOXvW MWS59lBxlIKWikaUcWyGK/AgfaZP2UeK2yXo5G12fyj+PAZiHlNziQX0yAV+ZVvIVFVJ bSM/ozKo0TUtTgwhk7LMpOX9zUNpR8U3LudKHOpj2KFEKqASUbDL6EU2o8WOSEqj20jH ge/0RbgcyeoNrCrw4qXhfii/rctAR0J0xf4uAnQxQsnaPZ/cpK7k0hTiXJZvd4jJw3YO pIsg== X-Gm-Message-State: APjAAAW8uqCVk/mEEiwxIJxdC1o7XzZUKVFA04v7LDR2TCIDMMuB8Zm5 tNABYK+J0lyYaAYpimWO0/Q8UCcfxTJ2 X-Google-Smtp-Source: APXvYqzfEDnU4rS8T+YWltksmDaJW6CvAiH7kmH8K7oI4QzX2riRkywtu3IEnjj05qbxnHTZEQl71nTrvMQd X-Received: by 2002:a63:778f:: with SMTP id s137mr25003421pgc.49.1580718459438; Mon, 03 Feb 2020 00:27:39 -0800 (PST) Date: Mon, 3 Feb 2020 16:27:16 +0800 In-Reply-To: <20200203082718.59614-1-tzungbi@google.com> Message-Id: <20200203151250.2.I1d568b0c99742c6e755d051aadfd52e4be3cc0a5@changeid> Mime-Version: 1.0 References: <20200203082718.59614-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-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] [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 b7d4bfd04b37..450fb1efa239 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), }, }; @@ -451,7 +510,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; @@ -485,12 +544,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 Mon Feb 3 08:27:17 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: 11362209 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 28FE0138D for ; Mon, 3 Feb 2020 08:30:47 +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 B437320658 for ; Mon, 3 Feb 2020 08: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="q3+VeaCW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Ww9WsRe0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B437320658 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 0CC9E168A; Mon, 3 Feb 2020 09:30:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0CC9E168A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1580718645; bh=Qy9FsU5ewVOVzxfc/uQz4ZDmmpZ4OSrsiw2HQWfHkx4=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=q3+VeaCWU/dTI175xShqz+8drzYgMfMpLDFHNdwapNOWOP4hGJDZ+gBObmuMCtEYF XkIw/PZvJbbL/euKrwFq4IY7DO8JH0vU3OWeBqlJ0DoKyhtMjZmUGQGldfuuqr6EuQ vGmVICPGFXC6qTvDTPQ3VEAr6Kp+ssPaFCcUH6w0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 98211F80279; Mon, 3 Feb 2020 09:27:53 +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 63C2CF80279; Mon, 3 Feb 2020 09:27:51 +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-vs1-xe4a.google.com (mail-vs1-xe4a.google.com [IPv6:2607:f8b0:4864:20::e4a]) (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 D135CF80273 for ; Mon, 3 Feb 2020 09:27:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D135CF80273 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ww9WsRe0" Received: by mail-vs1-xe4a.google.com with SMTP id s23so1270497vsl.9 for ; Mon, 03 Feb 2020 00:27:47 -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=0K1UnRjQODC0nNijTaG1o4tf21ySpZfP140PiAiGiBA=; b=Ww9WsRe0v6oeYy4U9K+OWzzDOZpmpjfnqqIHug84Hw/xdMrOgGYzJMwViYREzKANVh gcvRJQkPjfqooz/oIhEKF2u+OL7sEzlrC+LcT8w5cCeSGrrUYeaVizJwDjhXyRSoWfo4 PU8USp7/i9zcj5blvz3Q8493d748RC7vLVjdSoOoce+UPauxSEbS7kn/tiKaoudNheao rKN029MY4tQMWSFWxDZ6Q/teo1O+ppfvr3jcaSuIHtxUsaqKt7P5M39NJNsQJjZHrLsZ 3bjXv1CPffsIEQSmnYo5DXTA9ey0zz3RvrD3YTUhEAHw5cbWg+IIsS1M43jD9Tvgwbxa +ssA== 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=0K1UnRjQODC0nNijTaG1o4tf21ySpZfP140PiAiGiBA=; b=tRF29ct1knYKV9a0/HKBzoMMVGHkdtm+lg3F6n7gi+B96hJV3UvUoZiAPqa6PM6o0L 7ip+tlkKL0M9oZvtyMYD/HWlqkzJt/qieKrPxOzRHpl4D8hHsqwJA6o5u7nSfIk2OiiA 1XO49SruKXLBCW8bwdsESoaHyCsCBGZiDfDoNoUoX42zEr8eQjVwLvz+WKkOrO1pghUS tg8JJm4rQg4cVAmfO0WqQ8tl0BjHhlAUmxTHAJhbFX55hqcBMYic5lmm1m+kL3mCweXm AQAH212JGFblik5mYgU0u+pW2f5hUi4X3V0ILJsWW8euOAuByjKCriKWzmBkJJD2xskQ ccqw== X-Gm-Message-State: APjAAAUb67l+3dkCJ6tm+McAL8l4Denpebn/GpVGsMatJJQSyA3jOVdA k6LOagwu4s2i+Tr2d5EvvFIC1JGrBxqb X-Google-Smtp-Source: APXvYqyW6Ill+9/DDHwoTusyeTQLTCQYbQpaPUD9wUms3qnST+9r3Cm81IQdWqLCgAVou+GoVUMQHrqm2zfR X-Received: by 2002:a67:fc96:: with SMTP id x22mr13925669vsp.33.1580718464515; Mon, 03 Feb 2020 00:27:44 -0800 (PST) Date: Mon, 3 Feb 2020 16:27:17 +0800 In-Reply-To: <20200203082718.59614-1-tzungbi@google.com> Message-Id: <20200203151250.3.I30f0b8c87d5ec2a0e5f1b0fabf0a8ccef374f5ea@changeid> Mime-Version: 1.0 References: <20200203082718.59614-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-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] [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 450fb1efa239..7052210e8325 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 Mon Feb 3 08:27:18 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: 11362211 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 6DED2924 for ; Mon, 3 Feb 2020 08:31:00 +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 0441720721 for ; Mon, 3 Feb 2020 08:31:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="rxTjxp1N"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="jNlK2AFU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0441720721 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 496281698; Mon, 3 Feb 2020 09:30:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 496281698 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1580718658; bh=oos5Y3tEGJUvdtxY9fqysadngryLu3Tt0nq1/shd7iA=; h=Date:In-Reply-To:References:From:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rxTjxp1NazNoP/CtPm4ZmGzQgM8HNXX11USNODIMOdG3kKiyLpNzdgLM/vTgj0iyu kmeZ+eUrmKKoauM/tGWnVfdGDvTyd1jdmPlQ1EBhZaoyJqvdYLtdHDToIIZrSqTjFt QlZcmpvziAaBK49XI4ThiCaBFgbDRMvhq26deEow= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DCF0BF8027D; Mon, 3 Feb 2020 09:27:56 +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 BB9A9F8028A; Mon, 3 Feb 2020 09:27:55 +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,URIBL_BLOCKED, 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 D9ACCF80273 for ; Mon, 3 Feb 2020 09:27:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D9ACCF80273 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jNlK2AFU" Received: by mail-qv1-xf49.google.com with SMTP id z9so9022255qvo.10 for ; Mon, 03 Feb 2020 00:27:51 -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=4D3+flXDlkLj/FPRWkt9/EexkIE9XS3rKY8bH/Ln4QM=; b=jNlK2AFUWtL7A1/zZsh0g1YiSK9WW07lLanW+BrJcKXX/osBwI+OTRuSzAnQFYMsEy C1pCN4movrxAK/UNBcf56TT1JtCs7RzZfrJLhD2ukXEofiXFDZIVg1Xel+yJcOegFRXB FHO4t7I+nuFC1kfsLD6SMh5zPnnQfQFunipENg5SiEv0FAJLRBU1oy61CJfi5xsGop0Q 9xdAU9qwJ8qexzhWaReQHahhxduaiLgD9u9FMgjAhrX6FzHzZUKt7tjtbJrhfFgxG78S Rh+FrEBmzAFn9JlbkmqQIGGIZHHTrIYidZkliLHKPWPxFXYMNK5eFn34IawnpIz641qx oNAg== 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=4D3+flXDlkLj/FPRWkt9/EexkIE9XS3rKY8bH/Ln4QM=; b=VuEcQ1aDHili4xWAiqQyA+8WEgPP/NqZhJGOmzibuDF6JPatGNWrHTkCZ98Km48XKn zsLyRvKKz3maEZbNwqr9ekHYgcuKCRclH6QvIIU/C1hzn0inDOCczdwjfsnCiuGWtVKZ oKjJQQJdh21l7ZY5kHQ4D0qfl3EMF5viDsRL4BpNoiMNe2MiyMqVYpxpd6/tyPx473VI oPubPn13ZlPzPfzqnF20SjKUQAaCy56pRrPuN8cnSBJniRlzw6AY6E+6GhXJPtPsKmLO nTg/OFC0UZ9YZ0uaU8XhXmN09LVPQgVA1kDKj6I2sQDV/lISMta4aYgSjU4cC5SxYC5Q mKCg== X-Gm-Message-State: APjAAAWI2kvLXaWzufyVWrU7IjBI2QcQsUEWmrXnJf7Xb03ACFTzbb+0 8LwZRCHGakNkQ1YrphNBRby9qaHwqk1G X-Google-Smtp-Source: APXvYqxm4iTeJgEfhMOxqn3k/qpfFZr9inigo6scxMHuxKvPBzycRrh/QvVH3NBUZd+B5q98zaW0oVkv0Qiz X-Received: by 2002:ae9:ed4a:: with SMTP id c71mr8933538qkg.501.1580718469533; Mon, 03 Feb 2020 00:27:49 -0800 (PST) Date: Mon, 3 Feb 2020 16:27:18 +0800 In-Reply-To: <20200203082718.59614-1-tzungbi@google.com> Message-Id: <20200203151250.4.Ia542007f51d3de753a9e0a83135ee074581dbf71@changeid> Mime-Version: 1.0 References: <20200203082718.59614-1-tzungbi@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-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] [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 7052210e8325..ecc8082a824d 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, @@ -491,6 +490,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, @@ -498,12 +499,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; } @@ -540,13 +541,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; @@ -588,7 +582,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 @@ -615,4 +609,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"); -