From patchwork Wed Dec 13 12:35:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhua Lu X-Patchwork-Id: 754867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7103AC4167D for ; Thu, 14 Dec 2023 14:24:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 10E5A86E; Thu, 14 Dec 2023 15:23:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 10E5A86E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1702563842; bh=m/9IgX+05lDZCcP7jT/Hm266ZSa7Jj31op6alHjT/bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lnLkLUZqyqEpsGMZkQs+GIeSkFQdRkET7QAlxWR3AESAMaFadl8FsFlHiUQsHApee S64WmppSF5yEd+M6VLueiJ5JETRD5XLLHuQZi/fhQK4s9lK/QqloTfYHJE05COHcoV 0HSdfWZtoeFdy14/mW+yc+sVWpReeOlrp5Ve4Kjg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5D6D9F805EC; Thu, 14 Dec 2023 15:23:05 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B5194F805EA; Thu, 14 Dec 2023 15:23:04 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73F56F8016A; Wed, 13 Dec 2023 13:36:32 +0100 (CET) Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3EA89F80166 for ; Wed, 13 Dec 2023 13:36:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3EA89F80166 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=k9qFcPe/ Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5908a63a83fso3723448eaf.1 for ; Wed, 13 Dec 2023 04:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702470985; x=1703075785; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UeOaNUPzIaLpTYp3WoiPTDUVL3er+2u0oaLfnKfUysU=; b=k9qFcPe/e1P9rH/6xOzd9ddllMjCMtbhlHn4DXyoTiL+tQW9CKLRc5AuL0km+/cibD rVzMBk2s4cTBPxwaMG4vtr+Pg2GMzC8mzOBWB3ltFta9xzHWnzRqW0W5q/0mP7VqDJNX RGglVcftBBzDU5wulHHx7j7F3mELcSX2nn0QaWDcW66ikcnIHjtZmhouQ6GmZkgkIKzD HM8/22A5B+DDyHk4Ebu1r9KJ2HudvmP7xfwQCuHpQBvDQ4iK53/1j3HZq5JOqPYN5sCO xkbEXzcaYHkAgsPERaiZUmIXTUD6NIOq1882Obqj31BRpJL8eI6jwCS8vRzT5PoWKbvy Y1Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702470985; x=1703075785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UeOaNUPzIaLpTYp3WoiPTDUVL3er+2u0oaLfnKfUysU=; b=cHKTZP2Swc0/7D3gLXwm9HeTlLHWW5dps576Udh5+zhwt5w40V8y1Y3tdWDShgmG2d zEbKxnV3dD2oZCPDRrSYbKmnjwR+9kjK24a45PgvzVn9diEs1tusTqu6mtARCddA+1qe UnfMHBO+TIUxIA8aAGL5fjMt2KU8Nns27dX3qyPPrNiIAL5VwdHVwEI0NF4TcdQ1Mxoq 0HxY4ULeRq7CeUvuJ11IxfTcIk6MLo6WbWTHfCaXI/5bQAQMLO7kFTonujZpOTmGxIqv BOAADj7xTTg5RiCIv37mb6363S7Lel+m5kuHzMFX6GLBNHK84PBjzst3q1wmkSLGWpbz NYdA== X-Gm-Message-State: AOJu0Yyp3arFAUlFRtWUgQxq7fhh8ytczBy/+pMU0kM9otkow1R5FMTU vRrf71UoiGMR1uyFI4oJQPs= X-Google-Smtp-Source: AGHT+IF3mPmS92KpXb0fd2MbUmh0CWcpyP6e3laWEh/2A8gchCJz/2hR/V39DL3C2iJQDt7RFMyrgQ== X-Received: by 2002:a05:6358:70a:b0:170:cacc:f7ee with SMTP id e10-20020a056358070a00b00170caccf7eemr6977763rwj.8.1702470984986; Wed, 13 Dec 2023 04:36:24 -0800 (PST) Received: from localhost.localdomain ([117.189.237.103]) by smtp.gmail.com with ESMTPSA id x3-20020a056a00188300b0068fe5a5a566sm10193584pfh.142.2023.12.13.04.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 04:36:24 -0800 (PST) From: Jianhua Lu To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Jianhua Lu Subject: [PATCH v3 2/4] ASoC: qcom: sdm845: switch to qcom_snd_tdm_hw_params helper Date: Wed, 13 Dec 2023 20:35:54 +0800 Message-ID: <20231213123556.20469-2-lujianhua000@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231213123556.20469-1-lujianhua000@gmail.com> References: <20231213123556.20469-1-lujianhua000@gmail.com> MIME-Version: 1.0 X-MailFrom: lujianhua000@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: HQRUQVRDB3EPODZX3YABTPVTHLORWDEE X-Message-ID-Hash: HQRUQVRDB3EPODZX3YABTPVTHLORWDEE X-Mailman-Approved-At: Thu, 14 Dec 2023 14:22:54 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Use qcom_snd_tdm_hw_params helper to setup TDM ports. Signed-off-by: Jianhua Lu --- Changes in v3: 1. new patch sound/soc/qcom/sdm845.c | 46 +++++++---------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 252a0f0819be..5052c1410723 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -53,8 +53,6 @@ static struct snd_soc_jack_pin sdm845_jack_pins[] = { }, }; -static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; - static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -99,10 +97,9 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *codec_dai; int ret = 0, j; - int channels, slot_width; + int slot_width; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: @@ -114,39 +111,11 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - channels = params_channels(params); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0x3, - 8, slot_width); - if (ret < 0) { - dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", - __func__, ret); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, - channels, tdm_slot_offset); - if (ret < 0) { - dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", - __func__, ret); - goto end; - } - } else { - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xf, 0, - 8, slot_width); - if (ret < 0) { - dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", - __func__, ret); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, channels, - tdm_slot_offset, 0, NULL); - if (ret < 0) { - dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", - __func__, ret); - goto end; - } + ret = qcom_snd_tdm_hw_params(substream, params); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to setup TDM err:%d\n", + __func__, ret); + return ret; } for_each_rtd_codec_dais(rtd, j, codec_dai) { @@ -176,8 +145,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, } } -end: - return ret; + return 0; } static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, From patchwork Wed Dec 13 12:35:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhua Lu X-Patchwork-Id: 754866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D84F4C4332F for ; Thu, 14 Dec 2023 14:24:36 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0E655DF8; Thu, 14 Dec 2023 15:24:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0E655DF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1702563875; bh=WXB1c7ernYz0tJWArDKhx499nDcfaGA0MDoI3fa3ELE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RqgFfV+KNgmPzVV+HupYkg3a7DmGa9A90M7BQwah8fj7ijinqaU5vk1JdMHdefEb2 COn2hd3st3uf0ZO0YW3iRohRLEww/OP0FmoTYB5kjsNJVqMqv78yJ7DQ+vurtch9Ah MycbL1kGYKrwo88wSGsR9yGbunXoY1VwMWah01q8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 609B9F8063D; Thu, 14 Dec 2023 15:23:09 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 75EADF80633; Thu, 14 Dec 2023 15:23:09 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4FE5DF8016A; Wed, 13 Dec 2023 13:37:00 +0100 (CET) Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2A59AF8001F for ; Wed, 13 Dec 2023 13:36:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2A59AF8001F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Md5LqOaU Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5c210e34088so5613328a12.2 for ; Wed, 13 Dec 2023 04:36:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702471010; x=1703075810; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QZihwxl0v63j7g6/9Ub3zyT34OyL1Z04NfBICmYEzJk=; b=Md5LqOaUajfzGRoU5QK5XJqQg0olFalqpbXKXwMvZCewKYZswKLy4OKEUIMk5qXLP+ G2g5RXh2F00rGcdwYosm3fDATewnShZ/mxdEmIvsJUuU+9HlH+VU0C6yMzRawVaw2YBf jnpyHTIPun4O0mlYvUvf/OwjHy3vU3v0SshRs5vKj0OcXTVBV8QbUaAjN7PjjJOTqsyg NHFg6jXy8X0hfnGmcey1o5UOAnHXwgTAl9SA87dxInIpNuMSL9kQxy4+j9iGBBq+6QmE urt8VJImbvAkw/rfqSSdBpH8ojISJjQYab5Ew+Ad6v5d6mtjKiLLC6+zEJ5qSIJJ7PDL 5IBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702471010; x=1703075810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QZihwxl0v63j7g6/9Ub3zyT34OyL1Z04NfBICmYEzJk=; b=ZJ/3he9wMsWnD9c6dr6ThfrbsyuSPyiwLGnYs7Iry9N3z20QLFPSOio24tqLFJt5jT 696eLJ/W6WR9A3UdTzYIB/yFL2x1ZN1EjPD1ggxDVAhOopzbwJ5bu/awTrm5rY9h22rn X3VUxIo5fpIjBH27tOECPpy3Q+40hg+B0NWVmCjQOxHdpO2m4zV3V0RQT4L80lKxB20l ZjuTYyXNi4eb1mZWCcSQ8KhhPyRq4LPT7zRw2NYtrpG4EU5Ip9CyIkYL5B1TQ/fxPvdw TmQHLIHuAqPdXtCEywzPSxKLMMHWfejFSErMhJ9cuuUbUS/ePwV+JHUYxW3cDip85wYn DvUQ== X-Gm-Message-State: AOJu0YzTUCqnI1Zv87mf49b5LMOntNYMpTUO1mHvtG0iVOPwjlFG8rkx hmQVl5nHMg5WITfGkVQabFY= X-Google-Smtp-Source: AGHT+IEm5mEDtS1LOQPlg62W3tJlZX2ZCSTzqHOg/4SL8BX/XhHwx2CVtF+Cuq8ajRix5XT7ni3shg== X-Received: by 2002:a05:6a20:9481:b0:18b:4a28:6e15 with SMTP id hs1-20020a056a20948100b0018b4a286e15mr8029288pzb.34.1702471009861; Wed, 13 Dec 2023 04:36:49 -0800 (PST) Received: from localhost.localdomain ([117.189.237.103]) by smtp.gmail.com with ESMTPSA id x3-20020a056a00188300b0068fe5a5a566sm10193584pfh.142.2023.12.13.04.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 04:36:49 -0800 (PST) From: Jianhua Lu To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Jianhua Lu Subject: [PATCH v3 4/4] ASoC: qcom: sm8250: Add TERTIARY_TDM_RX_0 support Date: Wed, 13 Dec 2023 20:35:56 +0800 Message-ID: <20231213123556.20469-4-lujianhua000@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231213123556.20469-1-lujianhua000@gmail.com> References: <20231213123556.20469-1-lujianhua000@gmail.com> MIME-Version: 1.0 X-MailFrom: lujianhua000@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: WCE3USNLU5A34VDBU4NJM3PPDW6M3SJ6 X-Message-ID-Hash: WCE3USNLU5A34VDBU4NJM3PPDW6M3SJ6 X-Mailman-Approved-At: Thu, 14 Dec 2023 14:22:56 +0000 X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add TERTIARY_TDM_RX_0 case to make speaker amplifiers working on Xiaomi Pad 5 Pro tablet. Signed-off-by: Jianhua Lu --- No changes in v3. No changes in v2. sound/soc/qcom/sm8250.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index f298167c2a23..00c89c073e72 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -16,6 +16,7 @@ #define DRIVER_NAME "sm8250" #define MI2S_BCLK_RATE 1536000 +#define TDM_BCLK_RATE 12288000 struct sm8250_snd_data { bool stream_prepared[AFE_PORT_MAX]; @@ -53,6 +54,7 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); + int ret, j; switch (cpu_dai->id) { case TERTIARY_MI2S_RX: @@ -63,6 +65,23 @@ static int sm8250_snd_startup(struct snd_pcm_substream *substream) snd_soc_dai_set_fmt(cpu_dai, fmt); snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); break; + case TERTIARY_TDM_RX_0: + codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_DSP_A; + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT, + TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); + + for_each_rtd_codec_dais(rtd, j, codec_dai) { + ret = snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); + snd_soc_dai_set_sysclk(codec_dai, + 0, + TDM_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); + if (ret < 0) { + dev_err(rtd->dev, "TDM fmt err:%d\n", ret); + return ret; + } + } + break; default: break; }