From patchwork Wed Dec 13 12:35:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhua Lu X-Patchwork-Id: 13490843 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RBn/ou01" Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD130A4; Wed, 13 Dec 2023 04:36:10 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6cea5548eb2so6084863b3a.0; Wed, 13 Dec 2023 04:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702470970; x=1703075770; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rYGQmeoSqfkicHbElfiPvY8CF43myiqrL//zoYaASs8=; b=RBn/ou01ctheAZXDuwbzJmyOT9uxtab/kI9ipYWCqUJv0G9K6MS1CXSYK2SYAZCAD/ /rQFuxskJ9WDepLLmiCd+EgJBnpgs2TgIg6Edz2THkS6mJWQDJc0rynzdvJRyIZWMgFD XjYTfda0kMc2/mdnS1/e9Csyjq1IkPuqGFzSn9IHejOVEBDNPzSILBevyj6WcZFaJXgV SNf1W2Xq8FVRaP8Ey3TmnjRs/vAYaXjliXDZ+32DwE1iLsngA4JpSHI77JAwcfyyx0Dw p3iUrYqAbwNZCeXhTzapJy/wTyPAfPa+YnoI2USpX4K2uxXvIrDI4wwTeLh5jDWab6vK D+YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702470970; x=1703075770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rYGQmeoSqfkicHbElfiPvY8CF43myiqrL//zoYaASs8=; b=VoyFt6gp+IURhoFOOLZrnMNEXI2bm04cefBvoJYaK4jCbF5LZdOApOm5ACozuYc6Pj cIlIfbsccseJM5c4w0QnOpf6oeMAS2hazAq7gyzkK8VKzFTPB/+RQqy3+99tjM6cA0Lf dQ83HG5tndGFJ0v7LxDAsvNURP/3tZvXi9+LHK8ibQ4vuj+HVp17+5fcjoQpOQY8EkG5 0V5gd9iqBQLNZLOTDd95zaODROKMwpdO5B3t7TRE9ru9Oq8Nvcd5hAmk8EAD1zUMgRu4 0tQyubXjsY1SFFg8ja7qntBiN5zWPEub9jBlOyysyt2yO4m9gJBiUN37VDTuAJsf8k2/ gIaQ== X-Gm-Message-State: AOJu0Yx8a4ltvw7mCDmLKbxP8Lttf5t8m1lBoeqc7fc47zbHTUWfQ1fY hrcP1w0uvBTG8lkwhYfW4oM= X-Google-Smtp-Source: AGHT+IEbx8JLvsojpRz5MPXpDktCT7We9sURVnTHr4RL4smgdlCApyjvryZnRRvdKFVASMyp0xtahg== X-Received: by 2002:a05:6a00:2354:b0:6cd:e2c2:13d7 with SMTP id j20-20020a056a00235400b006cde2c213d7mr9982036pfj.23.1702470970088; Wed, 13 Dec 2023 04:36:10 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 04:36:09 -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 1/4] ASoC: qcom: common: Add qcom_snd_tdm_hw_params function Date: Wed, 13 Dec 2023 20:35:53 +0800 Message-ID: <20231213123556.20469-1-lujianhua000@gmail.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add qcom TDM setup function to support TDM ports for qcom platform. Signed-off-by: Jianhua Lu --- Changes in v3: 1. new patch 2. split qcom_snd_tdm_hw_params function from [Patch v2 1/2] to here sound/soc/qcom/common.c | 69 +++++++++++++++++++++++++++++++++++++++++ sound/soc/qcom/common.h | 2 ++ 2 files changed, 71 insertions(+) diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c index 483bbf53a541..c0ab201416ef 100644 --- a/sound/soc/qcom/common.c +++ b/sound/soc/qcom/common.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "common.h" @@ -13,6 +14,8 @@ static const struct snd_soc_dapm_widget qcom_jack_snd_widgets[] = { SND_SOC_DAPM_MIC("Mic Jack", NULL), }; +static unsigned int tdm_slot_offset[8] = { 0, 4, 8, 12, 16, 20, 24, 28 }; + int qcom_snd_parse_of(struct snd_soc_card *card) { struct device_node *np; @@ -239,4 +242,70 @@ int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd, return 0; } EXPORT_SYMBOL_GPL(qcom_snd_wcd_jack_setup); + +int qcom_snd_tdm_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); + int slots = ARRAY_SIZE(tdm_slot_offset); + int channels, slot_width, tx_mask, rx_mask; + int ret; + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S16_LE: + slot_width = 16; + break; + case SNDRV_PCM_FORMAT_S24_LE: + slot_width = 24; + break; + case SNDRV_PCM_FORMAT_S32_LE: + slot_width = 32; + break; + default: + dev_err(rtd->dev, "%s: invalid param format 0x%x\n", __func__, + params_format(params)); + return -EINVAL; + } + + channels = params_channels(params); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + tx_mask = 0; + rx_mask = BIT(channels) - 1; + ret = snd_soc_dai_set_tdm_slot(cpu_dai, tx_mask, rx_mask, slots, slot_width); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", + __func__, ret); + return ret; + } + + 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); + return ret; + } + } else { + tx_mask = 0xf; + rx_mask = 0; + ret = snd_soc_dai_set_tdm_slot(cpu_dai, tx_mask, rx_mask, slots, slot_width); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", + __func__, ret); + return ret; + } + + 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); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(qcom_snd_tdm_hw_params); MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/qcom/common.h b/sound/soc/qcom/common.h index d7f80ee5ae26..b583110f556e 100644 --- a/sound/soc/qcom/common.h +++ b/sound/soc/qcom/common.h @@ -9,5 +9,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card); int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd, struct snd_soc_jack *jack, bool *jack_setup); +int qcom_snd_tdm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params); #endif 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: 13490844 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fqb08ZxL" Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D3BF7; Wed, 13 Dec 2023 04:36:25 -0800 (PST) Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-58df5988172so4396923eaf.0; Wed, 13 Dec 2023 04:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702470985; x=1703075785; darn=vger.kernel.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=fqb08ZxLCs3Ujcy6Fg2rOrcDaTJsLcS+qLY6MnVCkd5AOiGrWxy+XyZdpXhQk5L5nd UY8xNQkGtiCZFw1J9Z2CNrm9dRC+bO0ULCrF3MwTNa9z9HiXSs35bVsoTm0MlMelG8Dw SBdNusbnJqskJXVgXpA0GIpIsnikmeh2ekwoc1HgSK03UKmqi2vSKfQcBHR5O0/QZS/4 PxibgluNvGc3u8Y1L4yZWw5tzHdHA9Mh0e+oJelUy8swZZA2o3yB1v5U4N3n/dHVQgga 37xF4vKw9Kh3ex1SYa9qNgH4rKs1787DedewRMcb21h7CnV7znDYRSYFxnkKvmKTfkoK amLg== 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=RvPdmViNtGT78k3n0mJLUhnLlf9VnkSSPC069ZcYswj98YApAmC2qzy0BsiMPCmmOt Dpx/+33TIsqSVZ+Qh6x8fhjTihoZdGH3fUcy/X6A5r9g6UQAbo+x4JHubvKxf8675jOw IR/KsCPxQCh2GcygmFbYcH6AXG4n4ZEDx3IacoG25hYkrrG5maYRJLZ0XEF5hQ4pImCH zyZyM6xIBnioOLVxBLBrmirMzIUP9lcvMdTHtCVc13FTYE1JV54R/FHEsUjJOSCEcj9b BnsSk5x/Zx2WvEyu8Gzj7+CPLRzkbLgfpeUDoDl732KQiYqKwquN06hPE2Orteg1HW57 Bz4g== X-Gm-Message-State: AOJu0YwqRkyphJteI8mQU8np8dz8WwnwJ2+4sqZb0hecfdXYcQspDogS zN+wJEIC3PFd4vmmbnHQLhI= 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> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhua Lu X-Patchwork-Id: 13490845 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UC5Fa1JZ" Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5A18E4; Wed, 13 Dec 2023 04:36:36 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ce26a03d9eso4326198b3a.0; Wed, 13 Dec 2023 04:36:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702470996; x=1703075796; darn=vger.kernel.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=6o9+b/zVNvA4/sI4WpDCuE/Pf6Swn7qoeIeF6jMIaTc=; b=UC5Fa1JZNxtJ5dxppPYVEvY+na6kHQuy6yE56hh2nlcCq5ZmjPYz3Ea+90G6+L7Azr JDjXS0uGvmpqHQ97gnyz2q0UL/Wh5hD6Ast0suEmWBfXMeoZm+eulbmluf1PZb8jImTs Mje3TH9VJUeeZdpXRhBJrXFkrCCWaa0vo4n/NryR+oq+q7ZyLvpzGLw6pVoL4Dgi8zML Xvy1sZEb7ibBqv6t7kbV4kaIsdsdfYi+15mSDYAJlMNY/ajbRhJLL1MlovCxxVm+ImHd aV3TovjOHy00k67Y5sFrlP8s4LSom1KQxrbXhcJvMtSdBbRkkcp1LoTyuORE6hbhIxNS sKCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702470996; x=1703075796; 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=6o9+b/zVNvA4/sI4WpDCuE/Pf6Swn7qoeIeF6jMIaTc=; b=C/zV1HLynB30mvKlpyw80I19q6JamLnyFJrnMwIdBYKMbHegre96nYjV4B4r8m07VC a+x2K6cv+m4fRti8A4mqG61mQ39vuiHsxyIRWqc1wf5sAuDno0ImBEBh6amcT+v7eRaC ElkdNDXvK7ULKVXLoUdxbUdWGdsNU3D4NmrKeC9wEROhqkj5dj9kXHrGLRIV0oY+z9Q/ ol2kL/9EtqjelobAnmp7T6o6Qmhew9/kO9osFUw7XYDeUKm8yHmw3Y0bEzpwQ3v4DHpz q3jIpiRRk6UA42Ps/3A4eUHoc2fW8odxwIrKUgEvmTmZ+BL9jFBa+5+q/TDG3HXUIxIS 21kg== X-Gm-Message-State: AOJu0Yw0Reo5+ewOdg8eepp+VblUgQhqxNnpdtqutcxtvtBoQpb+ube3 9UR2RdGzCcqGPrmYS9hPz/s2HPQn6HATgVF1 X-Google-Smtp-Source: AGHT+IGoI9nmTylJCkQMFXcqOVFTf2O9jztpOZQGEDTcSur6zbqLpwGGseS6UD76b141XTMjdovkrQ== X-Received: by 2002:a05:6a00:3305:b0:6ce:6007:9bb with SMTP id cq5-20020a056a00330500b006ce600709bbmr4308409pfb.60.1702470996273; Wed, 13 Dec 2023 04:36:36 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 04:36:35 -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 3/4] Asoc: qcom: sdw: Add TDM support Date: Wed, 13 Dec 2023 20:35:55 +0800 Message-ID: <20231213123556.20469-3-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> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Setup TDM ports when dai id is matched to *_TDM_*. Signed-off-by: Jianhua Lu --- Changes in v3: 1. split qcom_snd_tdm_hw_params function to common.c Changes in v2: 1. remove EXPORT_SYMBOL_GPL 2. remove static modifier sound/soc/qcom/sdw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c index 77dbe0c28b29..c07d878a1c18 100644 --- a/sound/soc/qcom/sdw.c +++ b/sound/soc/qcom/sdw.c @@ -5,6 +5,7 @@ #include #include #include +#include "common.h" #include "sdw.h" /** @@ -109,7 +110,7 @@ int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); struct sdw_stream_runtime *sruntime; - int i; + int ret, i; switch (cpu_dai->id) { case WSA_CODEC_DMA_RX_0: @@ -125,6 +126,14 @@ int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, *psruntime = sruntime; } break; + case PRIMARY_TDM_RX_0...QUINARY_TDM_TX_7: + 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; + } + break; } return 0; 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: 13490846 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yjqi5CFL" Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2D79113; Wed, 13 Dec 2023 04:36:50 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5c66e7eafabso5634605a12.0; Wed, 13 Dec 2023 04:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702471010; x=1703075810; darn=vger.kernel.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=Yjqi5CFL/PE1vUIRj+mjZ9GU2RM3WNzdRqOYkNos9IR7UrSyzqIweP4xDOci2mtN8m x7fzCQFwFNv3Sju6HGgVcCj1bDF5qnaP6bbwSu5+852srDk9c15JL/1XNZAzNR1NZtMR p+PuaFRpdGs/9KhuWZr2mUIY0746h4uiru7ofstA2gh9vaRJxVDD1Mq6OQ5GCyIIop89 uZwNL0vCIQZuY5Alc19fBOvgTasUwg8YGA/YiKyJAXAnsCS0v4St66GXAZ/YhgAMhR+e FJIeL0P3zGcZ0/3UML9K19A1gQ27m9FTU9edyFFxtIIoCObb4a2LWkN3W3sRkUZFOfHa g8MQ== 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=b7PFkwGb9XpAPzkzlhGFnrnGPdSgSK0C1B7iaFw+fuk8RexGjpWcGCNee0HlID849F E75tNjnGIy2zScpKLcQvQJmxJxUPrRqU5yF1fUJBBkjud127DavOw/00g6lVH6xu+Mg2 UK1UkEdCzl9eCTUzeq83+m795YmN5IhOGk28iiIf4JhQITRZV1KFDKArjWECP7Ciq95P 5d5FTvilFOKPDK+W18/MnzfJYNzYOPQqe3fn2RSRlZTIgiOGmwp9Aj28bgeDfTrq8lU8 lWHwmQRH+JjmSgCQ0TJqHUkdJKaBVoqNpN2bFei9ADHuMkJOItjeexYDGnE+jmaxqWJ3 U8Xw== X-Gm-Message-State: AOJu0YzpDhxJog+QEzY+1QwuO9SzOYOi2oJXRJUcvzH0yhHm307qCKr2 vTpSLbN6MUTLV9iKjOAdTM4= 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> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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; }