From patchwork Wed Nov 28 09:00:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10702089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F23315A8 for ; Wed, 28 Nov 2018 09:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EAB22CE04 for ; Wed, 28 Nov 2018 09:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19CF12CE33; Wed, 28 Nov 2018 09:00:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CD952CE04 for ; Wed, 28 Nov 2018 09:00:57 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id CAD18267AF4; Wed, 28 Nov 2018 10:00:55 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7FDA4267B01; Wed, 28 Nov 2018 10:00:53 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by alsa0.perex.cz (Postfix) with ESMTP id 1F2C5267AF3 for ; Wed, 28 Nov 2018 10:00:49 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id gn14so17079891plb.10 for ; Wed, 28 Nov 2018 01:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IUOy4aZ8sMVe6+qMyVL/vM/qr2CuqdP0B3o/v6hxFfA=; b=bdfFdrKDZrKggQ4uqk3ZzKRghc+LFCQdp1DM6NVZyUt1YwGaQLdz4WDYMdXkpfRo28 tI4mFgimoUggJKQI2Qj6KG9E8sJWDwXTs9A3LE5D6s/Dj3KqKViAuJBzRo0pMXFERH8V zo0T6fh2KGVVjMo7avspGBQkuAqDg1HkpkIrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IUOy4aZ8sMVe6+qMyVL/vM/qr2CuqdP0B3o/v6hxFfA=; b=k3TlBuZzHHRvZ5hsNgLbKC9OdMGBDKPzBDid+9XOF3hnSBVbkReJDEyS7aBRutB6ru DABsbmwU7UMsEl4/KJHIsexV4st1u/jozs0SYsYhLC8JgndGh+yFYNGRWnuKOMWZp8hu rnFJN4SOWFE8woWnXwmQ0sb/caDysD/TmcZQLA4haRgXcoWtdBuMB2AmJXxLy77arzsv pXmLtQvHGLTnAVJg37PDVergc9q2598mTlijQfZ4SSmucK4hs4qII9ndkAaGNulqRjpP 39hzb2jBvN8wLPNNNGET76wwzL/91IbOD+9KtFvy4Z7dUskevx4mJJmtuvc2ZyVwRLgl gQXw== X-Gm-Message-State: AA+aEWYKtd5BGOdIccvhtXlmvNxqY6St4hV4pj6H8KdDNuBjpYdXm+TN hecWaNniMZ5FjeRVyb0RzIS+Lw== X-Google-Smtp-Source: AFSGD/UlB7/+iwCyKUvjBqbaX6i2qOGc6R4dywm+eackpd9WbXVEwBwDBklbe7jgd11Yz8FA0oAInw== X-Received: by 2002:a17:902:20c8:: with SMTP id v8mr17457296plg.319.1543395649008; Wed, 28 Nov 2018 01:00:49 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i72sm11568607pfe.181.2018.11.28.01.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 01:00:47 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Wed, 28 Nov 2018 17:00:33 +0800 Message-Id: <20181128090037.257359-1-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH v2 1/5] ASoC: qcom: sdm845: Add board specific dapm widgets X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add board specific dapm widgets so these widgets can be used in the route. Signed-off-by: Rohit kumar Signed-off-by: Cheng-Yi Chiang --- sound/soc/qcom/sdm845.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 58593db2ab151..95d8d4422dae0 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -212,6 +212,14 @@ static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } +static const struct snd_soc_dapm_widget sdm845_snd_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Left Spk", NULL), + SND_SOC_DAPM_SPK("Right Spk", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), +}; + static void sdm845_add_be_ops(struct snd_soc_card *card) { struct snd_soc_dai_link *link; @@ -243,6 +251,8 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev) goto data_alloc_fail; } + card->dapm_widgets = sdm845_snd_widgets; + card->num_dapm_widgets = ARRAY_SIZE(sdm845_snd_widgets); card->dev = dev; dev_set_drvdata(dev, card); ret = qcom_snd_parse_of(card); From patchwork Wed Nov 28 09:00:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10702091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D377109C for ; Wed, 28 Nov 2018 09:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CCE82CE1C for ; Wed, 28 Nov 2018 09:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 412402CE37; Wed, 28 Nov 2018 09:01:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EA102CE33 for ; Wed, 28 Nov 2018 09:01:03 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 81240267B0E; Wed, 28 Nov 2018 10:01:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 54709267B0F; Wed, 28 Nov 2018 10:00:58 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by alsa0.perex.cz (Postfix) with ESMTP id 6470D267B0E for ; Wed, 28 Nov 2018 10:00:55 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id p8so6782514plo.2 for ; Wed, 28 Nov 2018 01:00:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1/yiL8MSzU0TPG6wYpvLbVxtNR5gac1eR3sg1WCS69w=; b=EjzPp3Vj30r+aaQN9fFDKU0gZUe9/1vuDU+RKl0wWU00nAvNfaC3TJvWo5Nmna3PSs xE7WoH6PslE7lzmfkgpryEhOtRGlKipQeTzAbsv/Z8PmOoFLK/0h1DfJTlGNjxmL0mfc FEhpKWckQEqqOGqnvyqNiH8P3Gcbx6W3PmYxs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1/yiL8MSzU0TPG6wYpvLbVxtNR5gac1eR3sg1WCS69w=; b=F+I3ifpWbVMgzelMrwHaNFg24GxF+h2LTdEohlxhF0IXOKnsPxPYAoZcFJHEG/8AOh 8P7D5NhScpBiMxts8BdhGqM3u0uT3ElKK9ifbNgbYvGu+NrQ9fP2jGQTj1UBCY8FqaXA L8eDkkO0o3sKWP+eNSqwuqDAEOXE/aDmTSnLLiqsj4O7l2dkUo97vfjn7SSFCOmREkEH TmBVU+lp+UstXY+XcSdzSCAiSf39Sh5dxUplgw1BjbUADWc3JVrJfDYyD6GlwyIMAndr fs6qWUz6cLVYZrYgAOhTvGeN5/4NNn0aQVMMWvzlkMTVUVBSvTd+1rG5hXPg7ioZwu70 Ytqw== X-Gm-Message-State: AA+aEWbkyNlyMDtkYQPsZG2/qLbmQObs2XQlvW0FBz5yvop91Lg24IE3 P8m/IH+OXW4nQuQTj0TFSW1buQ== X-Google-Smtp-Source: AFSGD/XiocVg9xvtj+pDwb2daqzCSNZlvID6QiPNZTmdLbOoIccPkgrIYlpypGJECd8e9HTLXPjMuw== X-Received: by 2002:a17:902:8d8e:: with SMTP id v14mr3527024plo.133.1543395654486; Wed, 28 Nov 2018 01:00:54 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i72sm11568607pfe.181.2018.11.28.01.00.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 01:00:53 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Wed, 28 Nov 2018 17:00:34 +0800 Message-Id: <20181128090037.257359-2-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181128090037.257359-1-cychiang@chromium.org> References: <20181128090037.257359-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH v2 2/5] ASoC: qcom: sdm845: Create and setup jack in init callback X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add a callback for init ops on dai_link to create and setup jack. Signed-off-by: Rohit kumar Signed-off-by: Cheng-Yi Chiang --- sound/soc/qcom/sdm845.c | 57 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 95d8d4422dae0..43c03f8e8cdc2 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "common.h" #include "qdsp6/q6afe.h" @@ -17,6 +19,8 @@ #define MI2S_BCLK_RATE 1536000 struct sdm845_snd_data { + struct snd_soc_jack jack; + bool jack_setup; struct snd_soc_card *card; uint32_t pri_mi2s_clk_count; uint32_t sec_mi2s_clk_count; @@ -100,6 +104,54 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, return ret; } +static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *component; + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_card *card = rtd->card; + struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card); + int i, rval; + + if (!pdata->jack_setup) { + struct snd_jack *jack; + + rval = snd_soc_card_jack_new(card, "Headset Jack", + SND_JACK_HEADSET | + SND_JACK_HEADPHONE | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3, + &pdata->jack, NULL, 0); + + if (rval < 0) { + dev_err(card->dev, "Unable to add Headphone Jack\n"); + return rval; + } + + jack = pdata->jack.jack; + + snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); + snd_jack_set_key(jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + pdata->jack_setup = true; + } + + for (i = 0 ; i < dai_link->num_codecs; i++) { + struct snd_soc_dai *dai = rtd->codec_dais[i]; + + component = dai->component; + rval = snd_soc_component_set_jack( + component, &pdata->jack, NULL); + if (rval != 0 && rval != -ENOTSUPP) { + dev_warn(card->dev, "Failed to set jack: %d\n", rval); + return rval; + } + } + + return 0; +} + + static int sdm845_snd_startup(struct snd_pcm_substream *substream) { unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; @@ -220,7 +272,7 @@ static const struct snd_soc_dapm_widget sdm845_snd_widgets[] = { SND_SOC_DAPM_MIC("Int Mic", NULL), }; -static void sdm845_add_be_ops(struct snd_soc_card *card) +static void sdm845_add_ops(struct snd_soc_card *card) { struct snd_soc_dai_link *link; int i; @@ -230,6 +282,7 @@ static void sdm845_add_be_ops(struct snd_soc_card *card) link->ops = &sdm845_be_ops; link->be_hw_params_fixup = sdm845_be_hw_params_fixup; } + link->init = sdm845_dai_init; } } @@ -264,7 +317,7 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev) data->card = card; snd_soc_card_set_drvdata(card, data); - sdm845_add_be_ops(card); + sdm845_add_ops(card); ret = snd_soc_register_card(card); if (ret) { dev_err(dev, "Sound card registration failed\n"); From patchwork Wed Nov 28 09:00:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10702093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A98F15A8 for ; Wed, 28 Nov 2018 09:01:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07C7A2CDEE for ; Wed, 28 Nov 2018 09:01:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F01C82CE37; Wed, 28 Nov 2018 09:01:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D6AA2CE38 for ; Wed, 28 Nov 2018 09:01:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 147C2267B16; Wed, 28 Nov 2018 10:01:04 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 67EDF267B16; Wed, 28 Nov 2018 10:01:02 +0100 (CET) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by alsa0.perex.cz (Postfix) with ESMTP id 542F5267AF3 for ; Wed, 28 Nov 2018 10:01:00 +0100 (CET) Received: by mail-pg1-f193.google.com with SMTP id 70so9198385pgh.8 for ; Wed, 28 Nov 2018 01:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AgtufxcsUbbhvbpoGvQbrCYqqvfC+nhS1gPzSq1nZsg=; b=R4DEGG3WzGXLxE/Xr3i1Bk9w7aN4nUT5Yx4BHnfpp+Tr09GeZMVqcUrlK4INlQDWAL Tr93wBMuIYPYXQUzNahuS2AUMKhiY3gf5mio86V4aP4BQlK/hZPMxpyjQ3XQxCupBnfa Eg1+Sj4egf5N3e/GL7iehXVY5hgSUhsbLDBl0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AgtufxcsUbbhvbpoGvQbrCYqqvfC+nhS1gPzSq1nZsg=; b=dt0v9U/hIcktEBcfOd+rfpDDfGr4iffMoNWSVh/T8U3PNA+lhAm1/arkcymHxRQ9Md OhkZfNFedRum6WjGVTkPMp2111SDsM1Jlv4DUISEfku9Z7oQ97G25CBuW5pibHm/V6b9 /KRH0XyOG3dij7KSnPPHbjKUiLV5n4ska7Htc5bfi/tsFsV2Biwu9uvdBjlO3vrLSdcC NU7ektI4bwYUrEYwPWS3dDdFjlbe7VIUwjlwHGK4chY/rodl6D/YI1kHDT2ueTq70inC MzVSIa30YrkLsQ06lMdXwhaKtKJFZjmN0TsZThwDbzKWvBhrAqr/nMm7TFnCMYjAbLZ1 dIBQ== X-Gm-Message-State: AA+aEWaifeL3PsdtFuwPk4bj+D5U0WfNCr5b3QMof5Oib266lDv2dcH/ QMw+PdKjm45FRIohcocIA3midw== X-Google-Smtp-Source: AFSGD/URYEiUsNt6OrAueQ5JPY4lPwDluFC7i/TPvfJ1ZOmUojls5Pfb5WKWRf1g7UyoVjd1epy0ew== X-Received: by 2002:a62:c3:: with SMTP id 186mr19911725pfa.24.1543395658927; Wed, 28 Nov 2018 01:00:58 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i72sm11568607pfe.181.2018.11.28.01.00.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 01:00:58 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Wed, 28 Nov 2018 17:00:35 +0800 Message-Id: <20181128090037.257359-3-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181128090037.257359-1-cychiang@chromium.org> References: <20181128090037.257359-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH v2 3/5] ASoC: sdm845: Add TDM configuration for speaker X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Set TDM time slots and DAI format for speaker codec. Signed-off-by: Cheng-Yi Chiang Acked-by: Srinivas Kandagatla --- sound/soc/qcom/sdm845.c | 69 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 43c03f8e8cdc2..d0df7ec6042e2 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -6,9 +6,11 @@ #include #include #include +#include #include #include #include +#include #include #include "common.h" #include "qdsp6/q6afe.h" @@ -17,6 +19,10 @@ #define DEFAULT_MCLK_RATE 24576000 #define TDM_BCLK_RATE 6144000 #define MI2S_BCLK_RATE 1536000 +#define LEFT_SPK_TDM_TX_MASK 0x30 +#define RIGHT_SPK_TDM_TX_MASK 0xC0 +#define SPK_TDM_RX_MASK 0x03 +#define NUM_TDM_SLOTS 8 struct sdm845_snd_data { struct snd_soc_jack jack; @@ -34,7 +40,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int ret = 0, j; int channels, slot_width; switch (params_format(params)) { @@ -81,6 +87,35 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, goto end; } } + + for (j = 0; j < rtd->num_codecs; j++) { + struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; + + if (!strcmp(codec_dai->component->name_prefix, "Left")) { + ret = snd_soc_dai_set_tdm_slot( + codec_dai, LEFT_SPK_TDM_TX_MASK, + SPK_TDM_RX_MASK, NUM_TDM_SLOTS, + slot_width); + if (ret < 0) { + dev_err(rtd->dev, + "DEV0 TDM slot err:%d\n", ret); + return ret; + } + } + + if (!strcmp(codec_dai->component->name_prefix, "Right")) { + ret = snd_soc_dai_set_tdm_slot( + codec_dai, RIGHT_SPK_TDM_TX_MASK, + SPK_TDM_RX_MASK, NUM_TDM_SLOTS, + slot_width); + if (ret < 0) { + dev_err(rtd->dev, + "DEV1 TDM slot err:%d\n", ret); + return ret; + } + } + } + end: return ret; } @@ -155,10 +190,14 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) static int sdm845_snd_startup(struct snd_pcm_substream *substream) { unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; + unsigned int codec_dai_fmt = SND_SOC_DAIFMT_CBS_CFS; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_card *card = rtd->card; struct sdm845_snd_data *data = snd_soc_card_get_drvdata(card); struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int j; + int ret; switch (cpu_dai->id) { case PRIMARY_MI2S_RX: @@ -190,6 +229,34 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT, TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); } + + codec_dai_fmt |= SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_DSP_B; + + for (j = 0; j < rtd->num_codecs; j++) { + codec_dai = rtd->codec_dais[j]; + + if (!strcmp(codec_dai->component->name_prefix, + "Left")) { + ret = snd_soc_dai_set_fmt( + codec_dai, codec_dai_fmt); + if (ret < 0) { + dev_err(rtd->dev, + "Left TDM fmt err:%d\n", ret); + return ret; + } + } + + if (!strcmp(codec_dai->component->name_prefix, + "Right")) { + ret = snd_soc_dai_set_fmt( + codec_dai, codec_dai_fmt); + if (ret < 0) { + dev_err(rtd->dev, + "Right TDM slot err:%d\n", ret); + return ret; + } + } + } break; default: From patchwork Wed Nov 28 09:00:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10702095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 523FA109C for ; Wed, 28 Nov 2018 09:01:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 422482CE48 for ; Wed, 28 Nov 2018 09:01:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 362622CDA9; Wed, 28 Nov 2018 09:01:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B9642CE20 for ; Wed, 28 Nov 2018 09:01:21 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7C127267B01; Wed, 28 Nov 2018 10:01:10 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 94F37267B1C; Wed, 28 Nov 2018 10:01:07 +0100 (CET) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by alsa0.perex.cz (Postfix) with ESMTP id 82DC1267B01 for ; Wed, 28 Nov 2018 10:01:03 +0100 (CET) Received: by mail-pf1-f194.google.com with SMTP id g62so9846406pfd.12 for ; Wed, 28 Nov 2018 01:01:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=obgcqLBzBg5HoHtorS/BUD2AZfJqzHsvR5ZV3gqGHws=; b=ghGMyBynlKFud8ocDfv99UI3c5MTXcF2I9SOwXZYkF7H54p4bY/t47igImDn1X37G/ uusi9ciVrliX9he9q8WzR+JkpENNclyaMN+eKGI41yqxdYBJ3ffi+ssGOJetmHSSboaO Fjwqs7rhh94o2Wn+4trZUkq7HTDlwYkmrvLA0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=obgcqLBzBg5HoHtorS/BUD2AZfJqzHsvR5ZV3gqGHws=; b=GEX2f0EjUKNiS6IM0GL03HOwCLlMYqGF9rlAzW+iWkmJ7JwWAL2OeuzsXBbVYg8E0K Hp/RJ38VTaW0xVlTMkNy3cPmlFUCFyp+7coi6G8B0uL66drQMPxMrph4VTuN/nAmT73i Iluwr++8rz2jCup+vilhnNGqwDCyuv3MaXb3hIkyYmNJbek5ybZHu/RxC8ORz1MQeOqW X2QEgNQQZ3pfFUKIN5FZ3dqovgVbsDfEVD9WINWep7MIWJDi9kzaBJXQA6+zSUbzBug/ wwHilofm/zeiut1h4NBw7q9ydbsOa9pqdgrhTh23Hz2m6RV6nGBYOP/0+xk07XoA1Yui QejQ== X-Gm-Message-State: AA+aEWbYJw54nRzEAPHs1kTTvdZQfS4r9Nvj4cneksbukPwCbLsiWeZV l2ia/7D6N3snY0cyQvAzhmGPlw== X-Google-Smtp-Source: AFSGD/VFOViiiurkCTAn3Dac8oDCy0FXKdT95jI0RD+wPdsm3WK/oRiCCfZAr+1/U4utuH/VaJwJcw== X-Received: by 2002:a62:c42:: with SMTP id u63mr4826704pfi.73.1543395662430; Wed, 28 Nov 2018 01:01:02 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i72sm11568607pfe.181.2018.11.28.01.01.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 01:01:01 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Wed, 28 Nov 2018 17:00:36 +0800 Message-Id: <20181128090037.257359-4-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181128090037.257359-1-cychiang@chromium.org> References: <20181128090037.257359-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH v2 4/5] ASoC: sdm845: Add configuration for headset codec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Set DAI format and sysclk for headset codec. Signed-off-by: Cheng-Yi Chiang Acked-by: Srinivas Kandagatla --- sound/soc/qcom/sdm845.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index d0df7ec6042e2..1db8ef6682233 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -14,6 +14,7 @@ #include #include "common.h" #include "qdsp6/q6afe.h" +#include "../codecs/rt5663.h" #define DEFAULT_SAMPLE_RATE_48K 48000 #define DEFAULT_MCLK_RATE 24576000 @@ -125,9 +126,27 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret = 0; switch (cpu_dai->id) { + case PRIMARY_MI2S_RX: + case PRIMARY_MI2S_TX: + /* + * Use ASRC for internal clocks, as PLL rate isn't multiple + * of BCLK. + */ + rt5663_sel_asrc_clk_src( + codec_dai->component, + RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, + RT5663_CLK_SEL_I2S1_ASRC); + ret = snd_soc_dai_set_sysclk( + codec_dai, RT5663_SCLK_S_MCLK, DEFAULT_MCLK_RATE, + SND_SOC_CLOCK_IN); + if (ret < 0) + dev_err(rtd->dev, + "snd_soc_dai_set_sysclk err = %d\n", ret); + break; case QUATERNARY_TDM_RX_0: case QUATERNARY_TDM_TX_0: ret = sdm845_tdm_snd_hw_params(substream, params); @@ -202,6 +221,7 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) switch (cpu_dai->id) { case PRIMARY_MI2S_RX: case PRIMARY_MI2S_TX: + codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF; if (++(data->pri_mi2s_clk_count) == 1) { snd_soc_dai_set_sysclk(cpu_dai, Q6AFE_LPASS_CLK_ID_MCLK_1, @@ -211,6 +231,7 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); } snd_soc_dai_set_fmt(cpu_dai, fmt); + snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); break; case SECONDARY_MI2S_TX: From patchwork Wed Nov 28 09:00:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10702097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB8E3109C for ; Wed, 28 Nov 2018 09:01:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBCAD2CE41 for ; Wed, 28 Nov 2018 09:01:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B03BF2CE4B; Wed, 28 Nov 2018 09:01:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BC302CE03 for ; Wed, 28 Nov 2018 09:01:32 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2F38C267B26; Wed, 28 Nov 2018 10:01:15 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 03960267B23; Wed, 28 Nov 2018 10:01:12 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by alsa0.perex.cz (Postfix) with ESMTP id 26866267B1C for ; Wed, 28 Nov 2018 10:01:10 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id u6so17073536plm.8 for ; Wed, 28 Nov 2018 01:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4mgb/onAr98Zp+HQOGZfPEtTRj6NtMnv3HBwE0KuWAw=; b=FHZOP6yfjv/1aN+klAGWOIfqI4ZZrKNlF/gncHnRxrapfezGDlW3eBfikbCz/Fy46a t1IwwF66dfkkFtFQqEx0k5xLMi4VUQgCb0jljIQxBFS7s+Oc4VMXJ+vulfZMCnN+eC9e VXJ/j18FlbceSIVFnYwwOx4pfotIkWIylzfTY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4mgb/onAr98Zp+HQOGZfPEtTRj6NtMnv3HBwE0KuWAw=; b=cFWwYOKTTNUazrQWDDPSNiU97AQBr2UlgABwrHm9Kf9GMc7sCRgCoxxSkEHNxTkUDU QE4Oj8EzPvIXt0hLQBZf+fU+4okJLIEIu0w7aCxn3u1D7Mw00nqEVwQ22CHfembxDuNF 0JQ4LQ3jtpzVKp07Hi+NxqVr0oJzkbUsi6uQeMpSEOvGa85WDkd/CTXyayhWC15N492e wMsKGXY1Q7f9dnNldEOYN1jvz9Ps95OulootDSUNKpE96yC+ERVzUyhSpLsKuViXAy85 zA1ZyKav/pZnHduvEdzKoMXHc6BC86GQmgSvCkgJ10nGruUeuq31qCBzgBwDQg9l06rO 4YQw== X-Gm-Message-State: AA+aEWZV5RQ2vV+Hjyk2vJbniHGCrdJBf0WQ+7zY1n7xgce5+5XOJHIx 8ECh+V2nlqPKCTQBJUcx6OLduw== X-Google-Smtp-Source: AFSGD/UdR8jr51W9aDnD0bPddU8RgUxUok8+X5uxCF3ab7j/GnwFSG9kf5f9hT3NtNiBMyknUmmXoA== X-Received: by 2002:a17:902:728c:: with SMTP id d12mr20791215pll.284.1543395669427; Wed, 28 Nov 2018 01:01:09 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id i72sm11568607pfe.181.2018.11.28.01.01.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 01:01:08 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Wed, 28 Nov 2018 17:00:37 +0800 Message-Id: <20181128090037.257359-5-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181128090037.257359-1-cychiang@chromium.org> References: <20181128090037.257359-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH v2 5/5] ASoC: qcom: Kconfig: select config for codec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Select SND_SOC_RT5663 and SND_SOC_MAX98927 for SND_SOC_SDM845. Signed-off-by: Rohit kumar Signed-off-by: Cheng-Yi Chiang --- sound/soc/qcom/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 2a4c912d1e484..3528c4279cbae 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -100,6 +100,8 @@ config SND_SOC_SDM845 depends on QCOM_APR select SND_SOC_QDSP6 select SND_SOC_QCOM_COMMON + select SND_SOC_RT5663 + select SND_SOC_MAX98927 help To add support for audio on Qualcomm Technologies Inc. SDM845 SoC-based systems.