From patchwork Sat Nov 24 11:09:45 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: 10696505 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 84E2314BD for ; Sat, 24 Nov 2018 11:47:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71BA12AB11 for ; Sat, 24 Nov 2018 11:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62AA82AB32; Sat, 24 Nov 2018 11:47:42 +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 EC6E02AB15 for ; Sat, 24 Nov 2018 11:47:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B919C267A7D; Sat, 24 Nov 2018 12:10:07 +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 0B806267A7F; Sat, 24 Nov 2018 12:10:06 +0100 (CET) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by alsa0.perex.cz (Postfix) with ESMTP id 7A5FB26786E for ; Sat, 24 Nov 2018 12:10:03 +0100 (CET) Received: by mail-pg1-f194.google.com with SMTP id 70so4052462pgh.8 for ; Sat, 24 Nov 2018 03:10: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:mime-version :content-transfer-encoding; bh=IUOy4aZ8sMVe6+qMyVL/vM/qr2CuqdP0B3o/v6hxFfA=; b=U5KrbeDOayGafnMfZXHDTR3LraAngU/khaaLGQjGG+XqRtz9DveBKxB+XPxxNm9VR3 i5iRRVls3kacbYHg5DVKSkzrZczpdjzvRX7sVMsL9RBQxNHsiTy27dqctMXPIH3tD16P n9oktsOcJgfAuRgvhgXYLuRcjWeYUWGX6BY3M= 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=sS1K56HglyEow13PH3TCo+z7mL98ivKC87tkJajkTz+Be+1Y+qW/CF/ZFmwkNSmMI+ GDnBWMhNH+rz5lCtv4bSKhayrqa8XNSQo7+uk7AwrC+pGomF6eeUlY7PSdwRhE53V6xH mIjx9apfh+QHURODoalnhG5Pz6f/42nHaWeYx1wW1/xVIK14bP3535JOjgDIfXyFwq71 COpngCcSORkBsOh6JKrhEtGL4KZfJdfuhr+zDKeclJmAVrShwpMPxY96nstmRecICt4Y tVJAIMdaD2GBBHO8xehCX/nOfLeWpWpIiBA2us+GEgntsRWlvo+1df84Lv6Q/Py8xmr0 YObQ== X-Gm-Message-State: AA+aEWYHj/7FAFgVVc3dEVamK+Pijq509EKIClV4ATQMBuuvfTRvl95i dWWqRsC4r7bskjt0/mU9hv3E2w== X-Google-Smtp-Source: AFSGD/UXLFP+4DfOkj/HXVi9bk2s07ptBhhw4EXV5ZjjjP3YnudAyj4pVUKVHaXdLZlj19y3rW5i0Q== X-Received: by 2002:a63:2744:: with SMTP id n65mr17384088pgn.65.1543057802205; Sat, 24 Nov 2018 03:10: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 v124-v6sm25098580pfb.182.2018.11.24.03.09.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Nov 2018 03:10:01 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Sat, 24 Nov 2018 19:09:45 +0800 Message-Id: <20181124110948.209019-1-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog MIME-Version: 1.0 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH 1/4] 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 Acked-by: Srinivas Kandagatla --- 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 Sat Nov 24 11:09:46 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: 10696509 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 E5DD913AD for ; Sat, 24 Nov 2018 11:47:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D431A2AB15 for ; Sat, 24 Nov 2018 11:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C882E2AB11; Sat, 24 Nov 2018 11:47:42 +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 0478A2AB23 for ; Sat, 24 Nov 2018 11:47:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 64509267A7F; Sat, 24 Nov 2018 12:10:20 +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 14906267A8A; Sat, 24 Nov 2018 12:10:18 +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 7BAFD267A8B for ; Sat, 24 Nov 2018 12:10:15 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id f12-v6so11691919plo.1 for ; Sat, 24 Nov 2018 03:10:15 -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=TunuNmpQxBki+ZFLPPWVDAYUffRWneeZP7KQnxXnCxQZRy7c8CdHwDTG8S33iJNMGa 3XNpRdcZ6EpfPkhN58ZGobr4qHWC9evH3xYI3MYg56qiuqK4yqJFZId31G5yNYqjJoXj sZC6QkwzdWBmytZBL8esBucfuMhC+h8XiTXkw= 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=JipCI+NDra3qNGoPLnFpjCHaxuxSaO3kvCqcoeiB03ET6EypJECdG4fS/2hh+23V7i uNaehDFNOcmFAlyG6XWFnE34s18iYJSuXbjGSUKUlpzwm/cKkPIZW3FDpD6nHriU1rP0 wbndiiG4jwumBuEG/xBnkK5sTwDyNclW6a6IVpbjPEPS0fglp7HKhgUipzQSE1my7+dh 6nKqi1OlM2jzquLVCu6DLXYXaJAQTlUcLAKLqIBjDce8O9D6EUk2YAiXNFoVslSmC30R /3u5VxuTFwTBoaSP/feUEl7U0oDiB5HNyEIJva41xsUUnuGktX04gQ6ImBWdPOw7uTqa nq+A== X-Gm-Message-State: AA+aEWZnx6SynQCtTFL00z3ocN3w9Dy+SUyV1oWuh/V2YeEUG+Ai43Sb aBxqts0X4BDkboOT9aTiWeQWtA== X-Google-Smtp-Source: AFSGD/WDhQtoCFmc1vAJmHWZvcxL7q29764rWg9RvpQj4zBA3uTrG5HW+BFsGhLiQheZiGVITZsveg== X-Received: by 2002:a17:902:9f89:: with SMTP id g9mr19642103plq.214.1543057812209; Sat, 24 Nov 2018 03:10:12 -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 v124-v6sm25098580pfb.182.2018.11.24.03.10.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Nov 2018 03:10:11 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Sat, 24 Nov 2018 19:09:46 +0800 Message-Id: <20181124110948.209019-2-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181124110948.209019-1-cychiang@chromium.org> References: <20181124110948.209019-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH 2/4] 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 Acked-by: Srinivas Kandagatla --- 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 Sat Nov 24 11:09:47 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: 10696511 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 95C8F18F0 for ; Sat, 24 Nov 2018 11:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8460A2AB11 for ; Sat, 24 Nov 2018 11:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78A4F2AB15; Sat, 24 Nov 2018 11:47:43 +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 F14BD2AB16 for ; Sat, 24 Nov 2018 11:47:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 204D8267A8E; Sat, 24 Nov 2018 12:10:29 +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 13AE7267A8A; Sat, 24 Nov 2018 12:10:27 +0100 (CET) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by alsa0.perex.cz (Postfix) with ESMTP id 0D5C6267A8F for ; Sat, 24 Nov 2018 12:10:22 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id f12-v6so11692031plo.1 for ; Sat, 24 Nov 2018 03:10:22 -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=6+oHEdKMDpuxzwVk64tZIxSsbb8yNe8+IDFvuSSfRD8=; b=nXDR/av+SQiZ1+gwoqkq/RVZ93mhWZVEBbciOefSoUVJlhXlFFLmiYXoCUIb4pDgjA CXYyFeJPY3O0r98qup97ze7vH151qM7HkFGgM8t4a3zjfd/bkw1jsrPhIsd9fWrS75KO iU1z/v/n0oyHDJ1C6Vf/honptjR41TsFmqafA= 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=6+oHEdKMDpuxzwVk64tZIxSsbb8yNe8+IDFvuSSfRD8=; b=dXCGeF6E0Ctzj/T8YtZeedfXpxAocqbM3xEAyCwGvO3ROa7PiIfUGAkmgpWWzxiG6h /3XaecbVsSl0YN9JjnLFwqnoALzRdIIsq5UhgG8EzXY72GLBdIW4U9ImlYHYPqrP8ePU IbVlx7RbeZYka0wAIV4sCnIvEt25Q9lu+F2fCvkZH4U7DqePV3CW1gvpAq7xLFofgdvt A/oazdcuwLa+i2naqxDEMJQuWo1ex5OW+TEUH/Bq8qT5jk1c60a3tyr4DTbQQy9OFpvw VpQSdegZsx0NtzpfROxewIpGVwUz0omrpnlilq9oAHoYCv3xrgrFHz/BE7l85gHISBO/ sSQQ== X-Gm-Message-State: AA+aEWbsD9li+WRGIafbgKkNX691oIKBwSSG5NJunDA4Lj0thjRWRmDH /dGG6PHwW4J6ahG8Vx/W/YJhlA== X-Google-Smtp-Source: AFSGD/VJ5pA0iSjWZrU0R2pZoLZanG+4lruFeYAQ4o8JLhBrSmx5SoJt4wfWok41GEfNdVxXKjUq9A== X-Received: by 2002:a17:902:a710:: with SMTP id w16mr19191099plq.95.1543057821327; Sat, 24 Nov 2018 03:10:21 -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 v124-v6sm25098580pfb.182.2018.11.24.03.10.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Nov 2018 03:10:20 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Sat, 24 Nov 2018 19:09:47 +0800 Message-Id: <20181124110948.209019-3-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181124110948.209019-1-cychiang@chromium.org> References: <20181124110948.209019-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH 3/4] ASoC: qcom: sdm845: Add codec related configuration for sdm845 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. Set DAI format and clock for headset. Signed-off-by: Rohit kumar Signed-off-by: Cheng-Yi Chiang --- sound/soc/qcom/sdm845.c | 82 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 43c03f8e8cdc2..d815040e98dc9 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -6,12 +6,15 @@ #include #include #include +#include #include #include #include +#include #include #include "common.h" #include "qdsp6/q6afe.h" +#include "../codecs/rt5663.h" #define DEFAULT_SAMPLE_RATE_48K 48000 #define DEFAULT_MCLK_RATE 24576000 @@ -34,7 +37,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 +84,31 @@ 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, 0x30, 0x3, 8, 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, 0xC0, 0x3, 8, slot_width); + if (ret < 0) { + dev_err(rtd->dev, + "DEV1 TDM slot err:%d\n", ret); + return ret; + } + } + } + end: return ret; } @@ -90,9 +118,26 @@ 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, 24576000, 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); @@ -155,14 +200,20 @@ 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: 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, @@ -172,6 +223,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: @@ -190,6 +242,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 Sat Nov 24 11:09:48 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: 10696507 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 C456318F0 for ; Sat, 24 Nov 2018 11:47:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1AED2AB11 for ; Sat, 24 Nov 2018 11:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A66A42AB15; Sat, 24 Nov 2018 11:47:42 +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 013522AB18 for ; Sat, 24 Nov 2018 11:47:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D3D24267A9C; Sat, 24 Nov 2018 12:10:32 +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 3F093267A9C; Sat, 24 Nov 2018 12:10:31 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by alsa0.perex.cz (Postfix) with ESMTP id 17F58267A94 for ; Sat, 24 Nov 2018 12:10:28 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id z9so4399264pfi.2 for ; Sat, 24 Nov 2018 03:10:28 -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=d0ARx8A+WX1e42Uh5lWN7otbm+NH7eyQ0Bda1t74BSmfXhYUvUOXIyTqd1PwMdgg4P HcyhE8YNV0z70pZQ87kuNzN1sf7522YuFRHQ0HaAgHvghFrQKmr28SCAw5OX320XQ+G5 a/8HdGj+6+KmFVH7jaB9SRMIo1jA8CNSiQwoU= 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=B53SraPWGu79xtb6x7Lw2PfNq89jBlKtO5tUtadvkUeYbLqDXirWoO1Rm2kuQKfF6A m3J9vZHj9jyypA5tUS8o9NjSWRjcrGIIE3dZHMCpl2VU+airwwtbdx4qnAv4f7FwWQc9 u/i265go2rRdUet0N9r/DhyaOPDfFQBRnVKA6qRlSdIcxsFlFg/Kf7AVBhetL+O5mpwx LDoTYOdGNcH/IsW4/Tw3EzDdB7Oa/uqBDbIPXtdDROaqlg2FRRSd/F8jT/eB4ZfjEOjb qLS57fMyrCwtPoInsWTUffdeW76XhuyMjLJIQjg9cmJEZ2EpYIwks33fDqOgwCGBFULo eYkg== X-Gm-Message-State: AGRZ1gITEfSyhlgoVOhYf0YnyF46AuyEb7YfGenwFVrE8ME4Go8VK91f Zg5L+Qhv2+5TOI182bqMZQXLAA== X-Google-Smtp-Source: AFSGD/XBpOsg7FAeqnnTg4Umo0/e1Ur0FQOQnxyH+zoJG7ylKD0blCzEdRCXXg0yKIkLHUoWTLl+Gg== X-Received: by 2002:a63:3d03:: with SMTP id k3mr17504778pga.191.1543057827561; Sat, 24 Nov 2018 03:10:27 -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 v124-v6sm25098580pfb.182.2018.11.24.03.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Nov 2018 03:10:26 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Sat, 24 Nov 2018 19:09:48 +0800 Message-Id: <20181124110948.209019-4-cychiang@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181124110948.209019-1-cychiang@chromium.org> References: <20181124110948.209019-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , Rohit kumar , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH 4/4] 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 Acked-by: Srinivas Kandagatla --- 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.