From patchwork Tue Dec 12 09:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhua Lu X-Patchwork-Id: 13488844 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MKtr751c" Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3BC4CF; Tue, 12 Dec 2023 01:59:05 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6cda22140f2so4745962b3a.1; Tue, 12 Dec 2023 01:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702375145; x=1702979945; 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=HC1jaqWj/hITC47c7fEay6ZWU1sK+rJ4SAKEml501iY=; b=MKtr751c+u4V482LxOVkbjfIMLON4uaJnEhxiF1ipuexb4TQlfVFZ4JYpPfG7QzUCM 8qRt0MmKnJe6WRtR86PbP0HY3roTIkkko2i6NXVG5sNXTfhnw0xETDuJCjbiMDUSJfbD viUWYEIp0IhP3zoMWLxs0yw+q4HUeFxqs07ZwUpx1bmPc9zdnKvSwygg82OeQWOUnKC0 Gltia01xPL54qyim3HOUcYkANai6OYnsUXVl4oVhnk4ZfbpoWP323JH6VU9VNOUJN8wD 3+heWadlJ5hVhvwYRPr4kOy5m9lju6l/JO2pzMVpCT2FWeSJpYTcbkOdWcSkjTlm4lpH Zb3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702375145; x=1702979945; 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=HC1jaqWj/hITC47c7fEay6ZWU1sK+rJ4SAKEml501iY=; b=voXIkASMBYJzToVIPcCoI+qvtCzeImX3nS2fsjeAOb9VkS8MbM09uzXAYoPapnjAHs CR//6uXpXOf83IIfMh6f6wAL+pvVsa8LKY8rooZbIm1vGYm6urvITFXRYve0XN5CR8Pj 9+zahgT6Owfi80x6tomLptZj/pqzrveH4AcL3SXO2u2Plwyo/r+E0vXZOYHOgNOEhr2S upuITrzDww7cNj3WS/PE696OW9uNTEBoFbf2R7qb5YqcbEIXMJUkAuFBumTb1W/gFUaW BOeMWypxdlMA+X3TanWIh3cXQVGbv2/CUPctdA96A83NKvH3WRCaltGDtqPMoPhXMr+0 ETPQ== X-Gm-Message-State: AOJu0YzupSxffbhApXT407LXJoZbSM1iXX7tb6caWu2hQsls0IcQDWuj 02p80DWbPUwgbuDBOHrt1QY= X-Google-Smtp-Source: AGHT+IF3oaoSk4UNEp37/FK6kt+vNA3UBT9+L9g7WytsaM7n4LaXWFmtLi9RLjt5/IHFTQnJSVkxVQ== X-Received: by 2002:a05:6a00:1913:b0:6cb:bc1a:dcff with SMTP id y19-20020a056a00191300b006cbbc1adcffmr7424793pfi.13.1702375144999; Tue, 12 Dec 2023 01:59:04 -0800 (PST) Received: from localhost.localdomain ([117.189.239.2]) by smtp.gmail.com with ESMTPSA id d4-20020a056a0010c400b006ce7344328asm7730354pfu.77.2023.12.12.01.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:59:04 -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: [RFC, PATCH v2 1/2] ASoC: qcom: sdw: Add TDM support Date: Tue, 12 Dec 2023 17:58:49 +0800 Message-ID: <20231212095850.26482-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 X-Patchwork-State: RFC Add qcom TDM setup function to support TDM ports for qcom platform. Signed-off-by: Jianhua Lu --- Changes in v2: 1. remove EXPORT_SYMBOL_GPL 2. remove static modifier sound/soc/qcom/sdw.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/sound/soc/qcom/sdw.c b/sound/soc/qcom/sdw.c index 77dbe0c28b29..948abbd2e0e3 100644 --- a/sound/soc/qcom/sdw.c +++ b/sound/soc/qcom/sdw.c @@ -4,6 +4,7 @@ #include #include +#include #include #include "sdw.h" @@ -101,6 +102,65 @@ int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, } EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare); +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); + unsigned int tdm_slot_offset[8] = { 0, 4, 8, 12, 16, 20, 24, 28 }; + int channels, slot_width; + 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) { + 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); + 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 { + 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); + 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; + } + } +} + int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct sdw_stream_runtime **psruntime) @@ -125,6 +185,9 @@ int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, *psruntime = sruntime; } break; + case PRIMARY_TDM_RX_0...QUINARY_TDM_TX_7: + qcom_snd_tdm_hw_params(substream, params); + break; } return 0; From patchwork Tue Dec 12 09:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianhua Lu X-Patchwork-Id: 13488845 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RAZnaZYK" Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F3B6E8; Tue, 12 Dec 2023 01:59:23 -0800 (PST) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3b9e7f4a0d7so3397424b6e.1; Tue, 12 Dec 2023 01:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702375162; x=1702979962; 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=p5GlMW1Kh4nLITNIYwe64bCuIn3y8U980DG6b5ax924=; b=RAZnaZYKgMyL1B2Fyn9AeuElVZFx46jgi1+pArhuVOg6mkW2LyN/qRoX6mferpQCeg +Pn4GkHaRpOOvho1t5/DDauWShQobmllCtBwoS8d3a9JJsEcIK4I6q4pHk7Fs8JAfmTB qMFfY84p5UKrQ3AxyDt39b9O9NYc2+AqyRGNMo1vp0Sa5ov6P2ME8z8TPpIS0IxmE2ac Wnj68YIqxOZKpNdi2FclRpNehNqIu6vPOy+ocGwnAkyhpD6rio+pyYtH2ljK0IDswRpF o/4h0eRVxBMvJAsLKGUFhADihImsj31fzrl/dQlTsuC4v0zV7fTkP4OS8b32snbxy9F1 u80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702375162; x=1702979962; 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=p5GlMW1Kh4nLITNIYwe64bCuIn3y8U980DG6b5ax924=; b=Elc3LCqqPeCN0VJgo2QUZrvpXtBrLy5yPqC8PLbT9CRFwjvsBMX8UAadpYs43IXmMH XxiY9xNwTZc/K5arhZJWcpmunIcGGlRzOp8Ht96pZJst0EiJjlE47fryENzQyP3we39L D7IYnL2LMf2SsfzDYNMHB1mGjnCzSNOeUjOS1psVzSYsOTT3t8YagjxhUaEXGYHk8Wrw BFhudByiIIgpFc7rV9mAK9UAWGYFStI/Ia4G5QSfeosHyxtL0gD6fp9qA23DliHw4tKD Jer7GGK13z1UCQK7LadoPZGVBi4euXXG/6w0FR2nBYc9ZTl/rJk1mNW3Q3zTYn7eExDa /zSw== X-Gm-Message-State: AOJu0Yxma/lQqkD946j0atEFX0bFN9xhumDebfBatmSRXyJNUX3QM3M3 yCtAWfN/BfM1zKiMVY6+od2EAutSItD6Qw== X-Google-Smtp-Source: AGHT+IGv+pUTcYw3AN16Fy3gEBQql0CgY9sI+VsP3TLi5giVX8oZb9syxSid0H88mpsNY3owKtMXEw== X-Received: by 2002:a05:6808:3028:b0:3a8:432a:ea13 with SMTP id ay40-20020a056808302800b003a8432aea13mr7516672oib.46.1702375162279; Tue, 12 Dec 2023 01:59:22 -0800 (PST) Received: from localhost.localdomain ([117.189.239.2]) by smtp.gmail.com with ESMTPSA id d4-20020a056a0010c400b006ce7344328asm7730354pfu.77.2023.12.12.01.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:59:21 -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: [RFC, PATCH v2 2/2] ASoC: qcom: sm8250: Add TERTIARY_TDM_RX_0 support Date: Tue, 12 Dec 2023 17:58:50 +0800 Message-ID: <20231212095850.26482-2-lujianhua000@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231212095850.26482-1-lujianhua000@gmail.com> References: <20231212095850.26482-1-lujianhua000@gmail.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-State: RFC Add TERTIARY_TDM_RX_0 case to make speaker amplifiers working on xiaomi-elish tablet. Signed-off-by: Jianhua Lu --- 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; }