Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4527597rdb; Tue, 12 Dec 2023 01:59:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtotPrDpyJ4Qoftp3Ay1rN3bQ/TaHzcWwHumiMQ8wuw2CzTicGEaTIHIA6RTwh0wgaVUyw X-Received: by 2002:a17:90a:b395:b0:285:85f5:4338 with SMTP id e21-20020a17090ab39500b0028585f54338mr5138632pjr.11.1702375159473; Tue, 12 Dec 2023 01:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702375159; cv=none; d=google.com; s=arc-20160816; b=e6/Jox9PGAq9vh6LzU9sfCx+H46B/LZ6tih4xqU+RJaISEy464nlU4Jlnzx71v73Fz TXmy6pT4HTksFaY3VYt5OAFNTWHOi/+VG5meqV7x0baw7AUM3jUDwoDMtMAkaqfXrY1e HU28Kj8/LuRInVyPFDFUv6Au23t9KSlVigmJJ9zhG9CjGnFo9+c2vw+xjaC8Dh1yd1Er c8UeL7Ycr4W+RYRq1H2CNPJu0CDn97udCazwpVgsr7GH+NRamv5RDegHSNpDYPcabSSb zikspktybIxQEIdfwq2eFoAsB/qur17MP4jKcGJ1mYvNOOYh8lIvCvHRE0D8UwAar2t2 icxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HC1jaqWj/hITC47c7fEay6ZWU1sK+rJ4SAKEml501iY=; fh=AjXMO6p+MtnAhJgZ2dXRvhWyXDMGQ+GS3ooIwv5cGEg=; b=Z+IYqxeM8BdxSMiliAI8Ap6SGditHc6Iel7BRv8zqY9MYrggIcm7Gs8GMli2hZeMbj uXpSNELCo2+esX/QwzMgIVCrjOdlXbl9i45MeYVVbybtai7rShGhY9Dt+dxmquT5g5Nz gG9P2g/AicIb89+2Qz3TGf/KaV4c06/8nC8uV6TlFxFe/61tfBt+DXHrF0ahi8mQaDFo CCs9SPY2Cc2qTckwKK0KG7rJVoNK6sz0yJ0sIbimi8kHSXtSkCUevjfXTRqMAq8+xnVS /ZzL7lp/7w+HfagPi+rBL4KSgtj9ZdHxm3jXKcsY4ASopdXuWzX4ekrP/eVcbY5FG+Pd b2xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MKtr751c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id na11-20020a17090b4c0b00b0028aa258b51bsi2247878pjb.5.2023.12.12.01.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:59:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MKtr751c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id AC79B80873CF; Tue, 12 Dec 2023 01:59:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbjLLJ7A (ORCPT + 99 others); Tue, 12 Dec 2023 04:59:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjLLJ67 (ORCPT ); Tue, 12 Dec 2023 04:58:59 -0500 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-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 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 12 Dec 2023 01:59:16 -0800 (PST) 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; -- 2.41.0